diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2023-01-15 21:51:44 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-15 21:51:44 +0000 |
| commit | cdcaf68c3a3ad454166b89cd3cf2436d363fddf4 (patch) | |
| tree | edcd2965b2e3932ef72832542556cb8028807daf | |
| parent | 7a09dcd3be8b1f7fdad61877812e8e0f2d89ff74 (diff) | |
| parent | 2046a883766e03e7cd477961991e1d1c81e02e5d (diff) | |
| download | perlweeklychallenge-club-cdcaf68c3a3ad454166b89cd3cf2436d363fddf4.tar.gz perlweeklychallenge-club-cdcaf68c3a3ad454166b89cd3cf2436d363fddf4.tar.bz2 perlweeklychallenge-club-cdcaf68c3a3ad454166b89cd3cf2436d363fddf4.zip | |
Merge pull request #7417 from arnesom/branch-for-challenge-199
Arne Sommer | update
| -rwxr-xr-x | challenge-199/arne-sommer/raku/ch-1.raku | 2 | ||||
| -rwxr-xr-x | challenge-199/arne-sommer/raku/good-pairs-map-shorter | 5 | ||||
| -rwxr-xr-x | challenge-199/arne-sommer/raku/good-pairs-test | 9 |
3 files changed, 15 insertions, 1 deletions
diff --git a/challenge-199/arne-sommer/raku/ch-1.raku b/challenge-199/arne-sommer/raku/ch-1.raku index 4f1e7cf383..7df80d95a7 100755 --- a/challenge-199/arne-sommer/raku/ch-1.raku +++ b/challenge-199/arne-sommer/raku/ch-1.raku @@ -2,4 +2,4 @@ unit sub MAIN (*@list where @list.elems > 0 && all(@list) ~~ /^<[0..9]>*$/); -say @list.Bag.values.map({ (" " xx $_).combinations(2).elems }).sum; +say @list.Bag.values.map({ (^$_).sum }).sum; diff --git a/challenge-199/arne-sommer/raku/good-pairs-map-shorter b/challenge-199/arne-sommer/raku/good-pairs-map-shorter new file mode 100755 index 0000000000..7df80d95a7 --- /dev/null +++ b/challenge-199/arne-sommer/raku/good-pairs-map-shorter @@ -0,0 +1,5 @@ +#! /usr/bin/env raku + +unit sub MAIN (*@list where @list.elems > 0 && all(@list) ~~ /^<[0..9]>*$/); + +say @list.Bag.values.map({ (^$_).sum }).sum; diff --git a/challenge-199/arne-sommer/raku/good-pairs-test b/challenge-199/arne-sommer/raku/good-pairs-test new file mode 100755 index 0000000000..1d86cea7da --- /dev/null +++ b/challenge-199/arne-sommer/raku/good-pairs-test @@ -0,0 +1,9 @@ +#! /usr/bin/env raku + +for 1 .. 100 -> $i +{ + my $comb = (" " xx $i).combinations(2).elems; + my $sum = (^$i).sum; + + say "$i: $comb vs $sum { $comb == $sum ?? "OK" !! "NOT OK" }"; +} |
