Files
advent-of-code-2021/08/01.sh
2021-12-08 11:48:58 +01:00

13 lines
393 B
Bash
Executable File

#!/bin/bash
n_found=0
while read line; do
number=' '$(sed -e 's/.* | //' -e 's/ / /g' <<< $line)' '
number=$(sed -e 's/ [a-z]\{2\} / 1 /g' -e 's/ [a-z]\{3\} / 7 /g' -e 's/ [a-z]\{4\} / 4 /g' \
-e 's/ [a-z]\{7\} / 8 /g' -e 's/ [a-z]\{5\} / /g' -e 's/ [a-z]\{6\} / /g' <<< $number)
found=${number// /}
i_found=${#found}
n_found=$((n_found+i_found))
done
echo $n_found