aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-160/2colours/raku/ch-1.raku7
-rwxr-xr-xchallenge-160/2colours/raku/ch-2.raku5
2 files changed, 12 insertions, 0 deletions
diff --git a/challenge-160/2colours/raku/ch-1.raku b/challenge-160/2colours/raku/ch-1.raku
new file mode 100755
index 0000000000..61c4614d83
--- /dev/null
+++ b/challenge-160/2colours/raku/ch-1.raku
@@ -0,0 +1,7 @@
+#!/usr/bin/env raku
+
+constant %digit-names = 0 => 'zero', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine';
+
+my $n = prompt('Input: $n = ');
+my @word-seq = ($n, { %digit-names{$_}.chars } ... 4).map({ %digit-names{$_} }).Slip, 'magic';
+say "Output: {@word-seq.rotor(2 => -1).map(*.join(' is ')).join(', ').tc}."; \ No newline at end of file
diff --git a/challenge-160/2colours/raku/ch-2.raku b/challenge-160/2colours/raku/ch-2.raku
new file mode 100755
index 0000000000..7e614e6b95
--- /dev/null
+++ b/challenge-160/2colours/raku/ch-2.raku
@@ -0,0 +1,5 @@
+#!/usr/bin/env raku
+
+my @n = prompt('Input: @n = ').comb(/\d+/)>>.Int;
+my $equilibrium-index is default(-1) = (^@n).first({ @n[^$_].sum == @n[$_^..*].sum });
+say "Output: $equilibrium-index"; \ No newline at end of file