Skip to content

Instantly share code, notes, and snippets.

@tdrhq
Created December 9, 2021 03:01
Show Gist options
  • Save tdrhq/779f43917d5439f8314484ec727b1e64 to your computer and use it in GitHub Desktop.
Save tdrhq/779f43917d5439f8314484ec727b1e64 to your computer and use it in GitHub Desktop.
(let ((points (mapcar #'parse-integer (str:split "," (car (uiop:read-file-lines "~/builds/web/input"))))))
(let ((state (make-array 10 :initial-element 0)))
(loop for point in points do
(incf (aref state point)))
(loop for day below 256 do
(progn
(let ((new (aref state 0)))
(loop for i from 0 below 8 do
(setf (aref state i)
(aref state (1+ i))))
(incf (aref state 6) new)
(setf (aref state 8) new))))
(loop for x across state summing x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment