Skip to content

Instantly share code, notes, and snippets.

@hlindberg
Created December 1, 2022 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlindberg/ecd2e5c90711c0b22c3d9e42a8235ef6 to your computer and use it in GitHub Desktop.
Save hlindberg/ecd2e5c90711c0b22c3d9e42a8235ef6 to your computer and use it in GitHub Desktop.
[ 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()
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