diff options
| -rw-r--r-- | challenge-100/markjreed/README | 6 | ||||
| -rwxr-xr-x | challenge-100/markjreed/perl/ch-1.sh | 2 | ||||
| -rw-r--r-- | challenge-100/markjreed/raku/ch-2.p6 | 18 |
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; |
