diff options
| author | Andrew Shitov <andy@shitov.ru> | 2020-08-30 14:25:52 +0200 |
|---|---|---|
| committer | Andrew Shitov <andy@shitov.ru> | 2020-08-30 14:25:52 +0200 |
| commit | 12aa1d033ed19a3e3019cf9f6f30b033b5baa1df (patch) | |
| tree | df99bdcbdcf9ba135750c21a9c659dbaa056837a /challenge-075 | |
| parent | 267719e907b8a1c636111ae9006ea190c9c2b840 (diff) | |
| download | perlweeklychallenge-club-12aa1d033ed19a3e3019cf9f6f30b033b5baa1df.tar.gz perlweeklychallenge-club-12aa1d033ed19a3e3019cf9f6f30b033b5baa1df.tar.bz2 perlweeklychallenge-club-12aa1d033ed19a3e3019cf9f6f30b033b5baa1df.zip | |
075-2 a more idiomatic Raku solution
Diffstat (limited to 'challenge-075')
| -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 |
