2020 day 24 (bash) part 1: simplify code

This commit is contained in:
2022-10-09 14:34:50 +02:00
parent cced357154
commit 563798871a

View File

@@ -27,21 +27,15 @@ while read -r line; do
;; ;;
esac esac
if [[ "$c" = e ]]; then if [[ "$c" = e ]]; then
(( x++ )) ((++x))
elif [[ "$c" = w ]]; then elif [[ "$c" = w ]]; then
(( x-- )) ((--x))
else else
printf "error c=%s\n" "$c" printf "error c=%s\n" "$c"
exit 1
fi fi
done done
printf "new tile at (%d,%d): " "$x" "$y" [[ -v plan[$x,$y] ]] && unset "plan[$x,$y]" || plan[$x,$y]=1
if [[ -v plan[$x,$y] ]]; then
printf "already set\n"
unset "plan[$x,$y]"
else
printf "new\n"
plan[$x,$y]=1
fi
done done
res=${#plan[@]} res=${#plan[@]}
printf "%s: res=%s\n" "$CMD" "$res" printf "%s: res=%s\n" "$CMD" "$res"