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:
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user