aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-128/feng-chang/raku/ch-1.raku17
-rwxr-xr-xchallenge-128/feng-chang/raku/ch-2.raku22
-rw-r--r--challenge-128/feng-chang/raku/in02.txt3
-rw-r--r--challenge-128/feng-chang/raku/input.txt3
-rw-r--r--challenge-128/feng-chang/raku/times.txt2
-rw-r--r--challenge-128/feng-chang/raku/tm02.txt2
6 files changed, 49 insertions, 0 deletions
diff --git a/challenge-128/feng-chang/raku/ch-1.raku b/challenge-128/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..367dbb470d
--- /dev/null
+++ b/challenge-128/feng-chang/raku/ch-1.raku
@@ -0,0 +1,17 @@
+#!/bin/env raku
+
+my method mat-size(List:D $coords where *.elems() == 4: --> UInt:D) {
+ ($coords[2] - $coords[0] + 1) * ($coords[3] - $coords[1] + 1)
+}
+
+sub MAIN(Str:D $f where *.IO.e = 'input.txt') {
+ my Array @mat .= push($_.comb.Array) for $f.IO.lines;
+
+ my @A = (^@mat.elems X ^@mat[0].elems X ^@mat.elems X ^@mat[0].elems)
+ .grep({ .[2] > .[0] and .[3] > .[1] })
+ .grep({ @mat[.[0] .. .[2]; .[1] .. .[3]].all == 0 });
+ my $max-size = @A.map(*.&mat-size).max;
+
+ put "max size: $max-size";
+ put @A.grep(*.&mat-size == $max-size).join("\n");
+}
diff --git a/challenge-128/feng-chang/raku/ch-2.raku b/challenge-128/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..1050c46bfc
--- /dev/null
+++ b/challenge-128/feng-chang/raku/ch-2.raku
@@ -0,0 +1,22 @@
+#!/bin/env raku
+
+subset TimeStr of Str where { $^s.match(/^ \d\d ':' \d\d $/) };
+
+my method mytime(TimeStr:D $t: --> DateTime:D) {
+ state Date $date = Date.new(now);
+ my ($hour, $minute) = $t.split(':');
+
+ DateTime.new(:$date, :$hour, :$minute)
+}
+
+sub MAIN(Str:D $f where *.IO.e = 'times.txt') {
+ my @lines = $f.IO.lines;
+ my @arrivals = @lines[0].words».&mytime;
+ my @departures = @lines[1].words».&mytime;
+
+ (|@arrivals, |@departures).map(-> $t {
+ (^@arrivals).grep(-> $i {
+ @arrivals[$i] ≤ $t ≤ @departures[$i]
+ }).elems
+ }).max.put;
+}
diff --git a/challenge-128/feng-chang/raku/in02.txt b/challenge-128/feng-chang/raku/in02.txt
new file mode 100644
index 0000000000..f8c64d269a
--- /dev/null
+++ b/challenge-128/feng-chang/raku/in02.txt
@@ -0,0 +1,3 @@
+0011
+0001
+0010
diff --git a/challenge-128/feng-chang/raku/input.txt b/challenge-128/feng-chang/raku/input.txt
new file mode 100644
index 0000000000..11c961ce70
--- /dev/null
+++ b/challenge-128/feng-chang/raku/input.txt
@@ -0,0 +1,3 @@
+100010
+110001
+100000
diff --git a/challenge-128/feng-chang/raku/times.txt b/challenge-128/feng-chang/raku/times.txt
new file mode 100644
index 0000000000..3bdd72d4d3
--- /dev/null
+++ b/challenge-128/feng-chang/raku/times.txt
@@ -0,0 +1,2 @@
+11:20 14:30
+11:50 15:00
diff --git a/challenge-128/feng-chang/raku/tm02.txt b/challenge-128/feng-chang/raku/tm02.txt
new file mode 100644
index 0000000000..a8ce4a8d1d
--- /dev/null
+++ b/challenge-128/feng-chang/raku/tm02.txt
@@ -0,0 +1,2 @@
+10:20 11:00 11:10 12:20 16:20 19:00
+10:30 13:20 12:40 12:50 20:20 21:20