diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-03-23 18:28:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-23 18:28:12 +0000 |
| commit | c41637fd66a222e5b19171b28c27fa498c8050de (patch) | |
| tree | d19ba307d758969f3e5afcb7da96dd807b925542 | |
| parent | 79645b6e55398688779aee58045e8339966c881d (diff) | |
| parent | 58191863fa68c268ca2a4d579abd52f643376064 (diff) | |
| download | perlweeklychallenge-club-c41637fd66a222e5b19171b28c27fa498c8050de.tar.gz perlweeklychallenge-club-c41637fd66a222e5b19171b28c27fa498c8050de.tar.bz2 perlweeklychallenge-club-c41637fd66a222e5b19171b28c27fa498c8050de.zip | |
Merge pull request #1456 from holli-holzer/master
less convoluted
| -rw-r--r-- | challenge-053/markus-holzer/raku/ch-2.p6 | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/challenge-053/markus-holzer/raku/ch-2.p6 b/challenge-053/markus-holzer/raku/ch-2.p6 index ff0d8689a6..57097d20af 100644 --- a/challenge-053/markus-holzer/raku/ch-2.p6 +++ b/challenge-053/markus-holzer/raku/ch-2.p6 @@ -1,32 +1,25 @@ my %rules = - :a({ $_ ~~ 'i'|'o' }), - :e({ $_ ~~ 'a'|'i'|'u' }), - :i({ $_ ~~ 'a'|'e' }), - :o({ $_ ~~ 'i'|'u' }), - :u({ $_ ~~ 'o'|'i' }) + :a('e','i'), + :e('i'), + :o('a','u'), + :u('e','o'), + :i('a','e', 'o', 'u') ; -my @vowels = <a e i o u>; - sub MAIN(Int $n) { - .say for gather { build-str( $n, $_ ) for @vowels } + .say for gather { build-str( $n, $_ ) for %rules.keys.sort } } multi sub build-str( $n, $current ) { my $last = $current.substr( * - 1, 1 ); - for @vowels + for |%rules{ $last } { - next - unless %rules{ $_ }( $last ); - given $current ~ $_ { - take $_ and next - if .chars == $n; - + take $_ and next if .chars == $n; build-str( $n, $_ ); } } |
