Login
7 branches 0 tags
Ben (Win10) Improved the bytecode evaluator quite a bit 7b8e04f 3 years ago 427 Commits
nujel / tests / fast / day6.nuj
#!/usr/bin/env nujel

[defun step [a]
       #[[a 1]
         [a 2]
	 [a 3]
	 [a 4]
	 [a 5]
	 [a 6]
	 [+ [a 7] [a 0]]
	 [a 8]
	 [a 0]]]

[defun do-steps [l count]
       [for [i 0 count]
            [set! l [step l]]]
       l]

[defun input/parse [l]
       [def ret #[0 0 0 0 0 0 0 0 0]]
       [while l
              [array/++ ret [car l]]
              [cdr! l]]
       ret]

[def input [input/parse [map [split [file/read "tests/fast/day6.input"] ","] int]]]
[def result [sum [do-steps input 80]]]
[when [!= result 349549]
      [throw [list :wrong-result "Wrong result" result]]]
[def result [sum [do-steps input 256]]]
[when [!= result 1589590444365]
      [throw [list :wrong-result "Wrong result" result]]]