02.sh (282B)
1 #!/bin/sh 2 3 elves="" 4 elf=0 5 6 while read -r line; do 7 if [ -z "$line" ]; then 8 elves="$elves $elf" 9 elf=0 10 continue 11 fi 12 elf=$(( elf + line )) 13 done 14 15 printf "%s" "$elves" | tr ' ' '\n' | sort -n | tail -n3 | while read -r line; do 16 tot=$(( tot + line )) 17 echo "$tot" 18 done | tail -n1