Solve AOC day 2 pt 1
This commit is contained in:
20
projects/aoc/src/year2021/day2.kiss
Normal file
20
projects/aoc/src/year2021/day2.kiss
Normal 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))
|
||||
Reference in New Issue
Block a user