diff options
Diffstat (limited to '2017/01/puzzle-2.sh')
-rwxr-xr-x | 2017/01/puzzle-2.sh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/2017/01/puzzle-2.sh b/2017/01/puzzle-2.sh new file mode 100755 index 0000000..f16db44 --- /dev/null +++ b/2017/01/puzzle-2.sh @@ -0,0 +1,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 }' |