;; Turn the input file into whatever form you will use for both parts ;; (get-file-lines) and (get-file-string) will be useful (defun 02/parse-input-direct (input) (let ((input (mapcar (lambda (s) (cl-ppcre:split " " s)) input))) (mapcar (lambda (x) (cons (intern (string-upcase (CAR x))) (parse-integer (CADR x)))) input))) (defun 02/parse-input (input-file) (02/parse-input-direct (get-file-lines input-file))) (defun 02/part-a (parsed-input) (let ((h 0) (v 0)) (dolist (i parsed-input) (case (car i) (forward (incf h (cdr i))) (up (decf v (cdr i))) (down (incf v (cdr i))))) (* h v))) (defun 02/part-b (parsed-input) (let ((h 0) (v 0) (a 0)) (dolist (i parsed-input) (case (car i) (forward (progn (incf v (* (cdr i) a)) (incf h (cdr i)))) (up (decf a (cdr i))) (down (incf a (cdr i))))) (* h v)))