Skip to content

Instantly share code, notes, and snippets.

@msgodf
Created December 3, 2022 14:43
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 msgodf/59f8af83af65e32fb101776c1384e4df to your computer and use it in GitHub Desktop.
Save msgodf/59f8af83af65e32fb101776c1384e4df to your computer and use it in GitHub Desktop.
Day 1, Puzzle 1 of AOC 2022
locals {
most_calories = reverse([for elf_calories in sort([for elf_calories in split(" ", replace(file("input1.txt"), "\n", " ")) : format("%08d", sum([for food_calories in split(" ", elf_calories) : food_calories == "" ? 0 : parseint(food_calories, 10)]))]) : tonumber(elf_calories)])[0]
}
output "answer" {
value = local.most_calories
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment