From 58191863fa68c268ca2a4d579abd52f643376064 Mon Sep 17 00:00:00 2001 From: "Markus \"Holli\" Holzer" Date: Mon, 23 Mar 2020 19:17:50 +0100 Subject: less convoluted --- challenge-053/markus-holzer/raku/ch-2.p6 | 23 ++++++++--------------- 1 file 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 = ; - 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, $_ ); } } -- cgit