(defun 01/parse-input-direct (input) (mapcar 'parse-integer input)) ;; Turn the input file into whatever form you will use for both parts ;; (get-file-lines) and (get-file-string) will be useful (defun 01/parse-input (input-file) (01/parse-input-direct (get-file-lines input-file))) ;; Loops through two item windows on input and counts each time the first is less than the second (defun 01/part-a (parsed-input) (let ((sum 0) (prev (car parsed-input))) (dolist (i (cons prev parsed-input)) (when (> i prev) (incf sum)) (setf prev i)) sum)) ;; Similar to part a, but with four item windows, comparing the sum of the first 3 with the next 3 (defun 01/part-b (parsed-input) (loop for (w x y z) on parsed-input until (null z) if (< (+ w x y) (+ x y z)) count w))