commit 84d1b3c3df3638f07004ca2f0d99e9f70eab3054 parent 2510fb91ba8ccb55706ff3de973d4f2a566e9de3 Author: alex wennerberg <alex@alexwennerberg.com> Date: Fri, 9 Dec 2022 23:56:24 -0800 Add day 10 part 1 Diffstat:
A | 2022/10.fs | | | 22 | ++++++++++++++++++++++ |
1 file changed, 22 insertions(+), 0 deletions(-)
diff --git a/2022/10.fs b/2022/10.fs @@ -0,0 +1,22 @@ +variable xreg +variable cycle +1 dup xreg ! cycle ! +45 constant minus + + +variable isminus +: to-num ( a u -- n ) +over c@ minus = dup isminus ! if 1 /string then +0 -rot 0 do dup i + c@ h# 30 - rot 10 * + swap loop drop +isminus @ if -1 * then ; + +variable signalsum +: signalcheck cycle @ dup 20 - 40 mod 0= + if xreg @ * signalsum +! else drop then ; +: dostep signalcheck 1 cycle +! ; + +: get-num bl parse to-num ; +: addx dostep dostep get-num xreg +! ; +: noop dostep ; +include input.txt +signalsum ?