diff options
| -rw-r--r-- | challenge-319/arne-sommer/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-319/arne-sommer/raku/ch-1.raku | 12 | ||||
| -rwxr-xr-x | challenge-319/arne-sommer/raku/ch-2.raku | 16 | ||||
| -rwxr-xr-x | challenge-319/arne-sommer/raku/minimum-common | 16 | ||||
| -rwxr-xr-x | challenge-319/arne-sommer/raku/word-count | 12 |
5 files changed, 57 insertions, 0 deletions
diff --git a/challenge-319/arne-sommer/blog.txt b/challenge-319/arne-sommer/blog.txt new file mode 100644 index 0000000000..1d7d8c84a2 --- /dev/null +++ b/challenge-319/arne-sommer/blog.txt @@ -0,0 +1 @@ +https://raku-musings.com/common-count.html diff --git a/challenge-319/arne-sommer/raku/ch-1.raku b/challenge-319/arne-sommer/raku/ch-1.raku new file mode 100755 index 0000000000..cc63a97d72 --- /dev/null +++ b/challenge-319/arne-sommer/raku/ch-1.raku @@ -0,0 +1,12 @@ +#! /usr/bin/env raku + +subset VOWEL where * ~~ /<[aeiouyAEIOUY]>/; + +unit sub MAIN (*@list where @list.elems > 1 && all(@list) ~~ /^<[a..z A..Z]>+$/, + :v(:$verbose)); + +my @matches = @list.grep({ .substr(0,1) ~~ VOWEL || .substr(.chars -1,1) ~~ VOWEL}); + +say ": Matching words: @matches[]" if $verbose; + +say @matches.elems ?? @matches.elems !! -1; diff --git a/challenge-319/arne-sommer/raku/ch-2.raku b/challenge-319/arne-sommer/raku/ch-2.raku new file mode 100755 index 0000000000..35de7d0f40 --- /dev/null +++ b/challenge-319/arne-sommer/raku/ch-2.raku @@ -0,0 +1,16 @@ +#! /usr/bin/env raku + +unit sub MAIN ($array_1, $array_2, + :v(:$verbose)); + +my @array_1 = $array_1.words; +my @array_2 = $array_2.words; + +die "Array1: Non-negative integers only" unless all(@array_1) ~~ /^<[0..9]>+$/; +die "Array2: Non-negative integers only" unless all(@array_2) ~~ /^<[0..9]>+$/; + +my @common = @array_1 (&) @array_2; + +say ": Common: { @common>>.key.sort.join(",")}" if $verbose; + +say @common ?? @common>>.key.sort.first !! -1;
\ No newline at end of file diff --git a/challenge-319/arne-sommer/raku/minimum-common b/challenge-319/arne-sommer/raku/minimum-common new file mode 100755 index 0000000000..35de7d0f40 --- /dev/null +++ b/challenge-319/arne-sommer/raku/minimum-common @@ -0,0 +1,16 @@ +#! /usr/bin/env raku + +unit sub MAIN ($array_1, $array_2, + :v(:$verbose)); + +my @array_1 = $array_1.words; +my @array_2 = $array_2.words; + +die "Array1: Non-negative integers only" unless all(@array_1) ~~ /^<[0..9]>+$/; +die "Array2: Non-negative integers only" unless all(@array_2) ~~ /^<[0..9]>+$/; + +my @common = @array_1 (&) @array_2; + +say ": Common: { @common>>.key.sort.join(",")}" if $verbose; + +say @common ?? @common>>.key.sort.first !! -1;
\ No newline at end of file diff --git a/challenge-319/arne-sommer/raku/word-count b/challenge-319/arne-sommer/raku/word-count new file mode 100755 index 0000000000..cc63a97d72 --- /dev/null +++ b/challenge-319/arne-sommer/raku/word-count @@ -0,0 +1,12 @@ +#! /usr/bin/env raku + +subset VOWEL where * ~~ /<[aeiouyAEIOUY]>/; + +unit sub MAIN (*@list where @list.elems > 1 && all(@list) ~~ /^<[a..z A..Z]>+$/, + :v(:$verbose)); + +my @matches = @list.grep({ .substr(0,1) ~~ VOWEL || .substr(.chars -1,1) ~~ VOWEL}); + +say ": Matching words: @matches[]" if $verbose; + +say @matches.elems ?? @matches.elems !! -1; |
