logo

adventofcode

Code used to solve https://adventofcode.com/, one branch per year git clone https://hacktivis.me/git/adventofcode.git

day1.1 (404B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2022 Haelwenn (lanodan) Monnier <contact+adventofcode@hacktivis.me>
  3. # SPDX-License-Identifier: BSD-3-Clause
  4. # Find the top three Elves carrying the most Calories. How many Calories are those Elves carrying in total?
  5. awk 'BEGIN { sum = 0 } { if(/^$/){ print sum; sum = 0 } else { sum += $1 } } END { print sum }' | sort -n | tail -3 | awk '{ i += $1 } END { print i }'