diff options
| author | brtastic <brtastic.dev@gmail.com> | 2021-04-23 17:27:15 +0200 |
|---|---|---|
| committer | brtastic <brtastic.dev@gmail.com> | 2021-04-23 17:27:15 +0200 |
| commit | b089884618833283a1e7e35e751d0fc877e6ed0b (patch) | |
| tree | 4f381f3d3554f51d8b596d2fc08566fac76d7be9 | |
| parent | b7394f415591b78ba0f96c31ce185d7c8663b584 (diff) | |
| download | perlweeklychallenge-club-b089884618833283a1e7e35e751d0fc877e6ed0b.tar.gz perlweeklychallenge-club-b089884618833283a1e7e35e751d0fc877e6ed0b.tar.bz2 perlweeklychallenge-club-b089884618833283a1e7e35e751d0fc877e6ed0b.zip | |
Challenge 109 solutions by brtastic
| -rw-r--r-- | challenge-109/brtastic/raku/ch-1.raku | 7 | ||||
| -rw-r--r-- | challenge-109/brtastic/raku/ch-2.raku | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/challenge-109/brtastic/raku/ch-1.raku b/challenge-109/brtastic/raku/ch-1.raku new file mode 100644 index 0000000000..fab08a6c80 --- /dev/null +++ b/challenge-109/brtastic/raku/ch-1.raku @@ -0,0 +1,7 @@ +for 1 .. 20 -> $num { + say [+] gather { + for 1 ^.. ($num / 2).truncate -> $divisor { + take $divisor if $num %% $divisor; + } + } +} diff --git a/challenge-109/brtastic/raku/ch-2.raku b/challenge-109/brtastic/raku/ch-2.raku new file mode 100644 index 0000000000..2495669858 --- /dev/null +++ b/challenge-109/brtastic/raku/ch-2.raku @@ -0,0 +1,16 @@ +constant $el-count = 7; + +sub four-squares(@input where .elems == $el-count --> Array[Map]) +{ + my Map @results; + for @input.permutations -> @case { + my @sum_groups = (0, |@case, 0).rotor(3 => -1); + + @results.push: %(flat zip 'a' .. 'g', @case) + if [==] @sum_groups.map: { [+] $_ }; + } + + return @results; +} + +say four-squares 1 .. 7; |
