From bab377cd85c27a372a72dd05949702c4e78f197b Mon Sep 17 00:00:00 2001 From: Lucas Ransan Date: Mon, 14 Jun 2021 21:22:04 +0200 Subject: Raku week 117 task 1 --- challenge-117/luc65r/README | 1 + challenge-117/luc65r/input.txt | 14 ++++++++++++++ challenge-117/luc65r/raku/ch-1.raku | 6 ++++++ 3 files changed, 21 insertions(+) create mode 100644 challenge-117/luc65r/README create mode 100644 challenge-117/luc65r/input.txt create mode 100755 challenge-117/luc65r/raku/ch-1.raku 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; +} -- cgit From a3e6903512e7724aabd32861216daa5fc501406e Mon Sep 17 00:00:00 2001 From: Lucas Ransan Date: Tue, 15 Jun 2021 02:05:04 +0200 Subject: Raku week 117 task 2 --- challenge-117/luc65r/raku/ch-2.raku | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 challenge-117/luc65r/raku/ch-2.raku 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 ; + +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] +} -- cgit