diff options
| author | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-09-28 09:11:47 +0100 |
|---|---|---|
| committer | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-09-28 09:11:47 +0100 |
| commit | 858ddb0bbe8c9c428431d2337110f99e1fc33c8b (patch) | |
| tree | cb9fb42782bf565ab3f2d8fef8626260133d1844 | |
| parent | ae5d269b72f3b247dfba99e434f9252bb5bb7f9b (diff) | |
| download | perlweeklychallenge-club-858ddb0bbe8c9c428431d2337110f99e1fc33c8b.tar.gz perlweeklychallenge-club-858ddb0bbe8c9c428431d2337110f99e1fc33c8b.tar.bz2 perlweeklychallenge-club-858ddb0bbe8c9c428431d2337110f99e1fc33c8b.zip | |
Candy counting
| -rw-r--r-- | challenge-080/simon-proctor/raku/ch-2.raku | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-080/simon-proctor/raku/ch-2.raku b/challenge-080/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..8da6fa6e0c --- /dev/null +++ b/challenge-080/simon-proctor/raku/ch-2.raku @@ -0,0 +1,13 @@ +#!/usr/bin/env raku + +use v6; + +#| Given a list of scores work out how many candies you need given these rules : +#| a) You must given at least one candy to each candidate. +#| b) Candidate with higher ranking get more candies than their mmediate neighbors on either side. +sub MAIN ( + *@N where { $_.all ~~ Int } #= List of scores +) { + my $max = @N.max + 1; + say [+] ($max, |@N, $max).rotor(3 => -2).map( -> ($l, $c, $r ) { [+] ($c > $l, 1, $c > $r ) } ) +} |
