aboutsummaryrefslogtreecommitdiff
path: root/challenge-064
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-06-15 00:39:49 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-06-15 00:39:49 +0100
commit4eb98f92f2ccf0ffb3637b7cb7b46f116c03b62a (patch)
treec54e9c94fd6ddd07f08c013028f60ddad32e43cb /challenge-064
parent89246f6d38156a805a660e8cc03d7c312b16328d (diff)
downloadperlweeklychallenge-club-4eb98f92f2ccf0ffb3637b7cb7b46f116c03b62a.tar.gz
perlweeklychallenge-club-4eb98f92f2ccf0ffb3637b7cb7b46f116c03b62a.tar.bz2
perlweeklychallenge-club-4eb98f92f2ccf0ffb3637b7cb7b46f116c03b62a.zip
- Added solutions by Shahed Nooshmand.
Diffstat (limited to 'challenge-064')
-rw-r--r--challenge-064/shahed-nooshmand/blog.txt1
-rw-r--r--challenge-064/shahed-nooshmand/raku/ch-1.p626
-rw-r--r--challenge-064/shahed-nooshmand/raku/ch-2.sh1
3 files changed, 28 insertions, 0 deletions
diff --git a/challenge-064/shahed-nooshmand/blog.txt b/challenge-064/shahed-nooshmand/blog.txt
new file mode 100644
index 0000000000..f82720c09d
--- /dev/null
+++ b/challenge-064/shahed-nooshmand/blog.txt
@@ -0,0 +1 @@
+https://rafraichisso.ir/2020/06/14/pwc-64
diff --git a/challenge-064/shahed-nooshmand/raku/ch-1.p6 b/challenge-064/shahed-nooshmand/raku/ch-1.p6
new file mode 100644
index 0000000000..ee1a40727d
--- /dev/null
+++ b/challenge-064/shahed-nooshmand/raku/ch-1.p6
@@ -0,0 +1,26 @@
+#!/usr/bin/env raku
+
+my @matrix = [1, 2, 3],
+ [4, 5, 6],
+ [7, 8, 9];
+say "{.sum} ({.join: ' → '})" given min paths(@matrix, 0, 0), by => &sum;
+
+
+sub paths(@matrix, $i, $j) {
+ my @paths;
+ my $pivot = @matrix[$i][$j];
+ my $right = @matrix[$i][$j+1];
+ my $down = @matrix[$i+1][$j];
+
+ with $right {
+ @paths.push: |paths(@matrix, $i, $j + 1).map: { $pivot, |$_ }
+ }
+ with $down {
+ @paths.push: |paths(@matrix, $i + 1, $j).map: { $pivot, |$_ }
+ }
+ without $right // $down {
+ return $pivot
+ }
+
+ return @paths
+}
diff --git a/challenge-064/shahed-nooshmand/raku/ch-2.sh b/challenge-064/shahed-nooshmand/raku/ch-2.sh
new file mode 100644
index 0000000000..9f4c3a01f3
--- /dev/null
+++ b/challenge-064/shahed-nooshmand/raku/ch-2.sh
@@ -0,0 +1 @@
+say $S ~~ m«^(@W)+$» ?? $0 !! 0