Last active
December 1, 2022 22:25
-
-
Save smortex/8b5b9d3fa999f9199a4b0975fc2b6fb1 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
$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 }) |
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
# 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