diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-08-30 13:55:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-30 13:55:31 +0100 |
| commit | ca1d0c619f40ad0a7dd7646f60b39a880264c9f7 (patch) | |
| tree | 8e8acf8f9a5f8d6f5af0c4d80194f1975105e664 | |
| parent | 38b34e632e124f5ce95a084c46c9132561a226c8 (diff) | |
| parent | 1af5be33de3988e52a5f8b232fb792df467df3ff (diff) | |
| download | perlweeklychallenge-club-ca1d0c619f40ad0a7dd7646f60b39a880264c9f7.tar.gz perlweeklychallenge-club-ca1d0c619f40ad0a7dd7646f60b39a880264c9f7.tar.bz2 perlweeklychallenge-club-ca1d0c619f40ad0a7dd7646f60b39a880264c9f7.zip | |
Merge pull request #2176 from ash/master
075-2 a more idiomatic Raku solution
| -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..f5b2dbfcf8 --- /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/30/a-more-idiomatic-raku-solution/ + +# 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 |
