tvl-depot/users/sterni/exercises/aoc/2022/10/10.bqn
sterni 4f1b55c27b refactor(sterni/aoc/2022/10): tidy up image rendering
Change-Id: I374373e86e78277cf2caf8509c477a508a2ceba1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7584
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
2022-12-12 23:48:17 +00:00

25 lines
876 B
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

SplitOn,ReadDec •Import "../../lib.bqn"
# Instead of implementing the VM described in the problem, translate the
# program to instructions with equivalent timing for a similar VM that
# only needs 1 cycle for every instruction.
is {"noop": <"noop"; 𝕩: (<"noop")<ReadDec(1) (<' ') SplitOn 𝕩}¨ •FLines "input"
Op {x 𝕊 "noop": x;x 𝕊 "addx"i: x+i}
Draw {𝕊 cxpic: pic(240)((c-1)=)((÷40)c)+¯1+x+3}
_vm {
is _self s: (s)is? s;
is _self prevsumxpic:
cycle prev+1
is _self
cycle,
sum+x×cycle×cycle2060100140180220,
x Op (¯1+cycle)is,
Draw cyclexpic
}
·sum·pic is _vm 101(2400)
•Out "day10.1: "•Fmt sum
•Out "day10.2:"
•Show ".#" ˜ 40pic