;; 17:04 ;; 17:34 part1 (ql:quickload '(fiveam str)) (defparameter eg-in "rn=1,cm-,qp=3,cm=2,qp-,pc=4,ot=9,ab=5,pc-,pc=6,ot=7") (defun hash (str) (reduce (lambda (acc c) (mod (* 17 (+ acc (char-code c))) 256)) str :initial-value 0)) (defun solve1 (in) (reduce #'+ (str:split "," (str:trim in)) :key #'hash)) (fiveam:test solutions (fiveam:is (= 52 (hash "HASH"))) (fiveam:is (= 1320 (solve1 eg-in))) (fiveam:is (= 506437 (solve1 (uiop:read-file-string "input"))))) (fiveam:run!)