day 4 part 1 not yet working
[aoc_eblake.git] / 2018 / day2a.sh
blobbadaabd6786d1324c8743e21c5e573f611d7501d
1 two=0
2 three=0
3 while read line; do
4 unset a
5 declare -A a
6 while [[ $line =~ (.)(.*) ]]; do
7 letter=${BASH_REMATCH[1]}
8 : $((a[$letter]++))
9 line=${BASH_REMATCH[2]}
10 done
11 have2=0 have3=0
12 for letter in {a..z}; do
13 if test "${a[$letter]}" = 2; then
14 have2=1
15 elif test "${a[$letter]}" = 3; then
16 have3=1
18 done
19 : $(( two += have2 )) $(( three += have3 ))
20 done
21 echo checksum: $(( two * three ))