Files
advent-of-code-2021/06/01.sh
2021-12-06 09:28:48 +01:00

18 lines
390 B
Bash
Executable File

#!/bin/bash
read line
anglerfishes=( ${line//,/ } )
for i in $(seq 80); do
new_anglerfishes=()
for j in $(seq ${#anglerfishes[@]}); do
if [ ${anglerfishes[$((j-1))]} -eq 0 ]; then
anglerfishes[$((j-1))]=7
new_anglerfishes+=( 8 )
fi
anglerfishes[$((j-1))]=$((anglerfishes[j-1]-1))
done
anglerfishes+=("${new_anglerfishes[@]}")
done
echo ${#anglerfishes[@]}