Solve AOC day 2 pt 1

This commit is contained in:
2021-12-03 13:58:16 -07:00
parent 26c1c56cf0
commit 40882d7a45
3 changed files with 1023 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
(defMacro readSubCommands [file &builder b]
(let [s (Stream.fromFile (eval file))
commands []]
(until (s.isEmpty)
(commands.push (b.call (read s) [(read s)]))
(s.dropWhitespace))
`(lambda [] ,(b.begin commands))))
(var &mut :Int subX)
(var &mut :Int subY)
(function simulateSubCommands [commands]
(set subX 0)
(set subY 0)
(commands)
[subX subY])
(function forward [x] (+= subX x))
(function down [x] (+= subY x))
(function up [x] (-= subY x))