aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-02-20 00:59:58 +0000
committerGitHub <noreply@github.com>2021-02-20 00:59:58 +0000
commit0ad84895a7963a232d0bc798ea1ee7b129240f1e (patch)
tree7b7084e466d4959f1807b648bb5529429be57350
parent1ff206561f4d0c69c76090c7765c818cd5ffed11 (diff)
parentf02ce77e12aa58847b0eac10ec9cf31b8b4c69ad (diff)
downloadperlweeklychallenge-club-0ad84895a7963a232d0bc798ea1ee7b129240f1e.tar.gz
perlweeklychallenge-club-0ad84895a7963a232d0bc798ea1ee7b129240f1e.tar.bz2
perlweeklychallenge-club-0ad84895a7963a232d0bc798ea1ee7b129240f1e.zip
Merge pull request #3575 from markjreed/ch-100-markjreed
markjreed solutions to challenge 100
-rw-r--r--challenge-100/markjreed/README6
-rwxr-xr-xchallenge-100/markjreed/perl/ch-1.sh2
-rw-r--r--challenge-100/markjreed/raku/ch-2.p618
3 files changed, 26 insertions, 0 deletions
diff --git a/challenge-100/markjreed/README b/challenge-100/markjreed/README
new file mode 100644
index 0000000000..7c94cbd1cf
--- /dev/null
+++ b/challenge-100/markjreed/README
@@ -0,0 +1,6 @@
+Solution by Mark J. Reed
+
+perl/ch-1.sh: perl one-liner to handle both conversion directions
+
+raku/ch-2.p6: somewhat lazy raku program that takes the triangle list as
+ a string and uses EVAL to parse it.
diff --git a/challenge-100/markjreed/perl/ch-1.sh b/challenge-100/markjreed/perl/ch-1.sh
new file mode 100755
index 0000000000..263a39d4a1
--- /dev/null
+++ b/challenge-100/markjreed/perl/ch-1.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+perl -lpe 's/(\d\d)(:\d\d)\s*([ap])m/sprintf "%02d$2", $1 + ($3 eq 'p' ? 12 : 0)/e || s/(\d\d)(:\d\d)\s*$/sprintf "%02d$2 %s", ($1 - 1) % 12 + 1, ($1 >= 12 ? "pm" : "am")/e'
diff --git a/challenge-100/markjreed/raku/ch-2.p6 b/challenge-100/markjreed/raku/ch-2.p6
new file mode 100644
index 0000000000..23298bda2f
--- /dev/null
+++ b/challenge-100/markjreed/raku/ch-2.p6
@@ -0,0 +1,18 @@
+#!/usr/bin/env raku
+unit sub MAIN($triangle-array);
+
+die "Illegal triangle array"
+ if $triangle-array ~~ /<-[ \[ \] 0 .. 9 , \s ]>/;
+
+use MONKEY-SEE-NO-EVAL;
+my @array = EVAL $triangle-array;
+my ($row, $col) = 0,0;
+my $len = @array[$row][$col];
+
+while ($row < @array - 1) {
+ $row = $row+1;
+ $col = ($col,$col+1).min( { @array[$row][$_] } );
+ $len += @array[$row][$col];
+}
+
+say $len;