day 15 golf more, 710 effective bytes
[aoc_eblake.git] / 2015 / advent1.sh
blobf8c1888ae0b40d88b6876d558e81e08187a8ec22
1 # part 1
2 echo $(( $(tr -d -c \( < day1.input | wc -c) - \
3 $(tr -d -c \) < day1.input | wc -c) ))
6 # part 2
7 i=0 floor=0
8 for act in $(sed 's/(/ +1/g; s/)/ -1/g' < day1.input); do
9 i=$((i+1)) floor=$((floor $act))
10 if test $floor -lt 0; then
11 echo $i
12 break
14 done