aboutsummaryrefslogtreecommitdiff
path: root/2017/01/puzzle-2.sh
blob: f16db44f216cea85417bb7ecf36da915bc3c7784 (plain) (blame)
1
2
3
4
5
6
#!/usr/bin/env sh

trap 'rm -f xa[ab]' EXIT
mid=$((`tr -d '\n' <input | wc -c` / 2))
sed 's/./&\n/g; s/\n$//' input | split -l $mid
paste xa[ab] | awk '$1 == $2 { s += $1 + $2 } END { print s }'