diff options
| -rwxr-xr-x | challenge-128/stuart-little/raku/ch-1.raku | 8 | ||||
| -rwxr-xr-x | challenge-128/stuart-little/raku/ch-2.raku | 15 |
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; |
