aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-160/simon-proctor/raku/ch-1.raku16
-rw-r--r--challenge-160/simon-proctor/raku/ch-2.raku13
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-160/simon-proctor/raku/ch-1.raku b/challenge-160/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..e01042edf1
--- /dev/null
+++ b/challenge-160/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+
+#| Given an integer between 1 and 9 print the four is magic chain for it
+sub MAIN(
+ Int() $a is copy where 0 < * < 10 #= Integer between 1 and 9
+) {
+ my @n=<<zero one two three four five six sever eight nine>>;
+ my @o;
+ while ( $a != 4 ) {
+ my $l = @n[$a].codes;
+ @o.push("{@n[$a]} is {@n[$l]}");
+ $a=$l;
+ }
+ @o.push("four is magic.");
+ @o.join(", ").tc.say
+}
diff --git a/challenge-160/simon-proctor/raku/ch-2.raku b/challenge-160/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..fb71aeeec1
--- /dev/null
+++ b/challenge-160/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+
+#| Given a list of numbers print any equilibrium indicies. Print -1 if there are none
+sub MAIN( *@a ) {
+ my $out = -1;
+ my $e = @a.end; for ( 0..$e ) -> $i {
+ if ( ([+] @a[^$i]) ~~ ([+] @a[$i^..$e]) ) {
+ say $i;
+ $out = '';
+ }
+ }
+ say $out if $out;
+}