diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-12-03 14:14:40 +0100 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-12-03 14:14:40 +0100 |
commit | 13f17fb1180375e64e02d1a3b9bc5faacc14c588 (patch) | |
tree | 51b66a7d0dcd19372b0369a4c93cfe7b278a2f96 /2017/01/puzzle-2.sh | |
parent | cacd416845e12bde1840508532474cb45e50a334 (diff) |
Add 2017 Day 1 solutions
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 }' |