AdventOfCode2022/01/day1-2.sh

3 lines
158 B
Bash
Raw Permalink Normal View History

2022-12-03 01:33:53 +01:00
#!/bin/bash
awk 'BEGIN{sum=0} {if (NF != 0) {sum+=$1} else {print sum; sum=0}}' input.txt | sort -n | tail -n 3 | awk 'BEGIN{sum=0} {sum+=$1} END{print sum}'