aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-06-15 20:15:53 +0100
committerGitHub <noreply@github.com>2021-06-15 20:15:53 +0100
commite20d8a99e28a925041194d41d113579a95a82c8e (patch)
tree7255ed5a5adc4d3c09b88276c649ca14dc56c387
parentd114bf057f6e40c3c74472bb784ad7a50ab62983 (diff)
parenta3e6903512e7724aabd32861216daa5fc501406e (diff)
downloadperlweeklychallenge-club-e20d8a99e28a925041194d41d113579a95a82c8e.tar.gz
perlweeklychallenge-club-e20d8a99e28a925041194d41d113579a95a82c8e.tar.bz2
perlweeklychallenge-club-e20d8a99e28a925041194d41d113579a95a82c8e.zip
Merge pull request #4269 from luc65r/117
Challenge 117
-rw-r--r--challenge-117/luc65r/README1
-rw-r--r--challenge-117/luc65r/input.txt14
-rwxr-xr-xchallenge-117/luc65r/raku/ch-1.raku6
-rwxr-xr-xchallenge-117/luc65r/raku/ch-2.raku37
4 files changed, 58 insertions, 0 deletions
diff --git a/challenge-117/luc65r/README b/challenge-117/luc65r/README
new file mode 100644
index 0000000000..ae1b87639b
--- /dev/null
+++ b/challenge-117/luc65r/README
@@ -0,0 +1 @@
+Solutions by Lucas Ransan
diff --git a/challenge-117/luc65r/input.txt b/challenge-117/luc65r/input.txt
new file mode 100644
index 0000000000..5b9d9ab1ce
--- /dev/null
+++ b/challenge-117/luc65r/input.txt
@@ -0,0 +1,14 @@
+11, Line Eleven
+1, Line one
+9, Line Nine
+13, Line Thirteen
+2, Line two
+6, Line Six
+8, Line Eight
+10, Line Ten
+7, Line Seven
+4, Line Four
+14, Line Fourteen
+3, Line three
+15, Line Fifteen
+5, Line Five
diff --git a/challenge-117/luc65r/raku/ch-1.raku b/challenge-117/luc65r/raku/ch-1.raku
new file mode 100755
index 0000000000..07d06622a7
--- /dev/null
+++ b/challenge-117/luc65r/raku/ch-1.raku
@@ -0,0 +1,6 @@
+#!/usr/bin/env raku
+
+sub MAIN(Str:D $file = '-') {
+ my @ns = $file.IO.lines».match(/\d+/)».UInt;
+ .key.say for (@ns.min .. @ns.max) ∖ @ns;
+}
diff --git a/challenge-117/luc65r/raku/ch-2.raku b/challenge-117/luc65r/raku/ch-2.raku
new file mode 100755
index 0000000000..f5ae5d6246
--- /dev/null
+++ b/challenge-117/luc65r/raku/ch-2.raku
@@ -0,0 +1,37 @@
+#!/usr/bin/env raku
+
+enum Move <H L R>;
+
+class Node {
+ also is Hash[Node, Move:D];
+
+ method dirs(Node:D: --> Iterable) {
+ gather {
+ for self.kv -> $k, $v {
+ with $v {
+ my @d = .dirs;
+ take $k ~ $_ for @d ?? @d !! '';
+ }
+ }
+ }
+ }
+}
+
+sub MAIN(UInt:D $size) {
+ my $top = construct-triangle($size);
+ .say for $top.dirs;
+}
+
+sub construct-triangle(UInt:D $size --> Node) {
+ my Node @line;
+ for $size … 0 -> $j {
+ for 0 .. $j -> $i {
+ @line[$i] = Node.new(
+ (H) => try { @line[$i - 1] },
+ (L) => @line[$i + 1],
+ (R) => @line[$i],
+ );
+ }
+ }
+ @line[0]
+}