diff options
| -rw-r--r-- | challenge-075/ash/blog3.txt | 1 | ||||
| -rw-r--r-- | challenge-075/ash/raku/ch-2a.raku | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-075/ash/blog3.txt b/challenge-075/ash/blog3.txt new file mode 100644 index 0000000000..0c8d84672d --- /dev/null +++ b/challenge-075/ash/blog3.txt @@ -0,0 +1 @@ +https://andrewshitov.com/2020/08/30/a-more-idiomatic-raku-solution/ diff --git a/challenge-075/ash/raku/ch-2a.raku b/challenge-075/ash/raku/ch-2a.raku new file mode 100644 index 0000000000..edcaf9c16d --- /dev/null +++ b/challenge-075/ash/raku/ch-2a.raku @@ -0,0 +1,21 @@ +#!/usr/bin/env raku + +# Task 2 from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-075/ + +# Comments: https://andrewshitov.com/2020/08/29/largest-rectangle-histogram-the-raku-challenge-week-75-task-2/ + +# my @hist = 2, 1, 4, 5, 3, 7; +my @hist = 3, 2, 3, 5, 7, 5; + +my $max = 0; +for (^@hist).combinations(2) -> ($x, $y) { + $max = max($max, min(@hist[$x .. $y]) * ($y - $x + 1)); +} + +say "The area of a biggest rectangle is $max."; + +# Output: +# +# $ raku ch-2a.raku +# The area of a biggest rectangle is 15.
\ No newline at end of file |
