diff options
| -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; |
