aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScimon <simon.proctor@gmail.com>2022-04-11 16:14:43 +0100
committerScimon <simon.proctor@gmail.com>2022-04-11 16:14:43 +0100
commit72b11ec48a23e1ac5da44c6f65ecd56af4fb5089 (patch)
treee0dab1582964732e1951ab160fcfaaf7065010ac
parent635f81890b1d36fd472afbe94df2c7cb0a289d6e (diff)
downloadperlweeklychallenge-club-72b11ec48a23e1ac5da44c6f65ecd56af4fb5089.tar.gz
perlweeklychallenge-club-72b11ec48a23e1ac5da44c6f65ecd56af4fb5089.tar.bz2
perlweeklychallenge-club-72b11ec48a23e1ac5da44c6f65ecd56af4fb5089.zip
Challenge 1 and 2
-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;
+}