Created
December 1, 2022 21:28
-
-
Save hlindberg/ecd2e5c90711c0b22c3d9e42a8235ef6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ 1000, 2000, 3000, "", 4000, "", 5000, 6000, "", 7000, 8000, 9000, "", 10000, | |
].reduce([0]) |$memo, $v| { if $v == "" { $memo << 0 } else { $memo[0,-2] << $memo[-1]+$v } } | |
.map() |$i,$x| { [$i,$x] } | |
.sort() |$a,$b| { compare($b[1], $a[1]) } | |
.then() |$x| { $x[0] } | |
.then() |$x| { "Elf ${x[0]} has ${x[1]} calories" } | |
.notice() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puppet apply advent.pp | |
Notice: Scope(Class[main]): Elf 3 has 24000 calories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment