diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-03-27 02:15:07 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-03-27 02:15:07 +0000 |
| commit | a899f2647c231dab288f83af85bee2deb49f19d9 (patch) | |
| tree | e684dcfc411b7f2781a60ac4982919451a359d87 /challenge-053/mohammad-anwar | |
| parent | 3893d476fcb0f54450e6c208e3548c251f0f65c2 (diff) | |
| download | perlweeklychallenge-club-a899f2647c231dab288f83af85bee2deb49f19d9.tar.gz perlweeklychallenge-club-a899f2647c231dab288f83af85bee2deb49f19d9.tar.bz2 perlweeklychallenge-club-a899f2647c231dab288f83af85bee2deb49f19d9.zip | |
- Added Raku solution to the Vowel String task.
Diffstat (limited to 'challenge-053/mohammad-anwar')
| -rw-r--r-- | challenge-053/mohammad-anwar/raku/ch-2.p6 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/challenge-053/mohammad-anwar/raku/ch-2.p6 b/challenge-053/mohammad-anwar/raku/ch-2.p6 new file mode 100644 index 0000000000..2db2c332e8 --- /dev/null +++ b/challenge-053/mohammad-anwar/raku/ch-2.p6 @@ -0,0 +1,36 @@ +#!/usr/bin/env perl6 + +use v6.c; + +sub MAIN(Int $count = 2) { + die "ERROR: Invalid count $count.\n" + unless $count ~~ any (1, 2, 3, 4, 5); + + my @chars = <a e i o u>; + + if $count == 1 { + say @chars.join("\n"); + exit; + } + + my @char-sets = @chars.combinations: $count; + my @comb-sets = @char-sets.map({ .join }); + + my @rules = ( + rx/ a<[ie]> /, + rx/ e<[i]> /, + rx/ i<[aeou]> /, + rx/ o<[au]> /, + rx/ u<[oe]> /, + ); + + for @comb-sets -> $str { + my $pass = False; + for @rules -> $rule { + if $str ~~ /$rule/ { + $pass = True; + } + } + say $str if $pass; + } +} |
