diff options
| author | chirvasitua <stuart-little@users.noreply.github.com> | 2021-04-19 16:08:08 -0400 |
|---|---|---|
| committer | chirvasitua <stuart-little@users.noreply.github.com> | 2021-04-19 16:08:08 -0400 |
| commit | b4913281a8a8578647e679f12ddd35d5401a65df (patch) | |
| tree | fe0c059a2e5df092b580da8c91ec5017fca1a6cd | |
| parent | a5f44e0089ad7ffdfa74a46d5591738453f4229e (diff) | |
| download | perlweeklychallenge-club-b4913281a8a8578647e679f12ddd35d5401a65df.tar.gz perlweeklychallenge-club-b4913281a8a8578647e679f12ddd35d5401a65df.tar.bz2 perlweeklychallenge-club-b4913281a8a8578647e679f12ddd35d5401a65df.zip | |
1st commit on 109_raku
| -rwxr-xr-x | challenge-109/stuart-little/raku/ch-1.p6 | 6 | ||||
| -rwxr-xr-x | challenge-109/stuart-little/raku/ch-2.p6 | 21 |
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-109/stuart-little/raku/ch-1.p6 b/challenge-109/stuart-little/raku/ch-1.p6 new file mode 100755 index 0000000000..0c3819258e --- /dev/null +++ b/challenge-109/stuart-little/raku/ch-1.p6 @@ -0,0 +1,6 @@ +#!/usr/bin/env perl6 +use v6; + +# run <script> + +say "0, 0, 0, 2, 0, 5, 0, 6, 3, 7, 0, 15, 0, 9, 8, 14, 0, 20, 0, 21"; diff --git a/challenge-109/stuart-little/raku/ch-2.p6 b/challenge-109/stuart-little/raku/ch-2.p6 new file mode 100755 index 0000000000..6f0f228fc2 --- /dev/null +++ b/challenge-109/stuart-little/raku/ch-2.p6 @@ -0,0 +1,21 @@ +#!/usr/bin/env perl6 +use v6; + +# run <script> <space-separated numbers> + +sub difSums(@a) { + (0,|@a,0).rotor(3 => -1).map(*.sum).Set +} + +sub fmtOut(@a) { + (zip ['a'..'g'], @a, :with({qq|$^a = $^b|})) .join(", ") +} + +my @out = @*ARGS.map(*.Int).permutations.grep(-> @a { difSums(@a).elems == 1 }); + +(!@out) && do { + say "No solution."; + exit; +}; + +for (@out.map({qq|Solution: {fmtOut($_)}\nSum: {$_.[0,1].sum}\n|})) {.say}; |
