aoc-2022/01/meow.sh

18 lines
218 B
Bash
Executable file

#!/bin/bash
n=1
[[ "$1" != '' ]] && n=$1
meow=()
sum=0
while read line; do
if [[ "$line" == '' ]]; then
meow+=($sum)
sum=0
else
sum=$((sum+line))
fi
done
echo ${meow[@]} | tr ' ' '\n' | sort -n | tail -n$n