2022 day 10: C, parts 1 and 2. Should be useful if this "machine"...

... comes back in next days puzzles (my guess is that it will ;-)
This commit is contained in:
2022-12-18 14:33:45 +01:00
parent 17e140f235
commit 18720b9e09
3 changed files with 190 additions and 10 deletions

View File

@@ -18,11 +18,10 @@ declare -i cycle=0 regx=1
draw() {
local -i pos
if (( cycle % 40 )); then
(( pos = cycle % 40 - regx - 1, pos = pos < 0? -pos: pos ))
(( pos < 2 )) && res+="#" || res+="."
else
res+=.$'\n'
(( pos = cycle % 40 - regx - 1, pos = pos < 0? -pos: pos ))
(( pos < 2 )) && res+="#" || res+="."
if ! (( cycle % 40 )); then
res+=$'\n'
fi
}