aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-08-30 18:30:29 -0400
committerchirvasitua <stuart-little@users.noreply.github.com>2021-08-30 18:30:29 -0400
commitfeb7a345c2a7dd820412cee1865617817ab32acf (patch)
tree44fa072d2a2f6826a522bfd41bf561f47dc61d6f
parentc778b5d4e001fd074f4f0e2cf3ca0ed873e17afe (diff)
downloadperlweeklychallenge-club-feb7a345c2a7dd820412cee1865617817ab32acf.tar.gz
perlweeklychallenge-club-feb7a345c2a7dd820412cee1865617817ab32acf.tar.bz2
perlweeklychallenge-club-feb7a345c2a7dd820412cee1865617817ab32acf.zip
1st commit on 128_raku
-rwxr-xr-xchallenge-128/stuart-little/raku/ch-1.raku8
-rwxr-xr-xchallenge-128/stuart-little/raku/ch-2.raku15
2 files changed, 23 insertions, 0 deletions
diff --git a/challenge-128/stuart-little/raku/ch-1.raku b/challenge-128/stuart-little/raku/ch-1.raku
new file mode 100755
index 0000000000..8c23d55e29
--- /dev/null
+++ b/challenge-128/stuart-little/raku/ch-1.raku
@@ -0,0 +1,8 @@
+#!/usr/bin/env raku
+use v6;
+
+# run <script> <space-separated binary words, with one word representing each row>
+
+my $tup = (((0..^@*ARGS.elems) X (0..^@*ARGS.elems)).grep({ $_[0] <= $_[1]}) X ((0..^@*ARGS[0].chars) X (0..^@*ARGS[0].chars)).grep({ $_[0] <= $_[1] })).grep( -> $pr { @*ARGS[$pr[0][0]..$pr[0][1]].map( -> $str {$str.substr($pr[1][0], 1+$pr[1][1]-$pr[1][0])} ) !~~ /1/ }).max({ ($_[1][1]-$_[1][0]+1)*($_[0][1]-$_[0][0]+1) });
+
+say (('0' x ($tup[1][1] - $tup[1][0] + 1)) xx ($tup[0][1] - $tup[0][0] + 1)).join("\n")
diff --git a/challenge-128/stuart-little/raku/ch-2.raku b/challenge-128/stuart-little/raku/ch-2.raku
new file mode 100755
index 0000000000..cc654d89e1
--- /dev/null
+++ b/challenge-128/stuart-little/raku/ch-2.raku
@@ -0,0 +1,15 @@
+#!/usr/bin/env raku
+use v6;
+
+# run <script> <starting arrivals followed by departures, all space-separated>
+
+my @times = (@*ARGS Z [0..^@*ARGS.elems]).map({ [$_[0], $_[1] % (floor(@*ARGS.elems/2))] }).sort({ $_[0] });
+my $sol=0;
+my @station = 0 xx floor(@*ARGS/2);
+
+for (@times) {
+ @station[$_[1]]+^=1;
+ (@station.sum > $sol) && do {$sol = @station.sum};
+}
+
+say $sol;