Skip to content

Instantly share code, notes, and snippets.

@smortex
Last active December 1, 2022 22:25
Show Gist options
  • Save smortex/8b5b9d3fa999f9199a4b0975fc2b6fb1 to your computer and use it in GitHub Desktop.
Save smortex/8b5b9d3fa999f9199a4b0975fc2b6fb1 to your computer and use it in GitHub Desktop.
$each_elf_carry_as_string = file('aoc/day1.txt').split('\n\n')
$each_elf_carry_as_array_of_integers = $each_elf_carry_as_string.map |$value| { $value.split('\n').map |$value| { Integer($value) } }
$each_elf_total_carry = $each_elf_carry_as_array_of_integers.map |$carry| { $carry.reduce |$memo, $value| { $memo + $value } }
warning($each_elf_total_carry.max)
warning($each_elf_total_carry.sort[-3, -1].reduce |$memo, $value| { $memo + $value })
# bolt apply day1.pp -t localhost
localhost: Scope(Class[main]): 69289
localhost: Scope(Class[main]): 205615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment