Login
7 branches 0 tags
Benjamin Vincent Schulenburg Moved ansi escape sequences into a module db0d12b 3 years ago 865 Commits
nujel / tests / fast / day6.nuj
#!/usr/bin/env nujel

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

[defn do-steps [l count]
       [dotimes [i count l]
                [set! l [step l]]]]

[defn 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.dat"] ","] read/int]]]
[def result [sum [do-steps input 80]]]
[when [not= result 349549]
      [throw [list :wrong-result "Wrong result" result]]]
[def result [sum [do-steps input 256]]]
[when [not= result 1589590444365]
      [throw [list :wrong-result "Wrong result" result]]]

[return :success]