Initial commit

This commit is contained in:
2022-12-02 12:22:50 +01:00
commit 53da572ca6
5 changed files with 4867 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
(defun parse-rounds (input)
(cl-ppcre:split "\\n" (uiop:read-file-string input)))
(defun calc-points-one (round)
(let* ((round (uiop:split-string round :separator " "))
(p1 (intern (first round)))
(p2 (intern (second round))))
(cond ((eq 'A p1)
(cond ((eq 'X p2)
(+ 1 3))
((eq 'Y p2)
(+ 2 6))
((eq 'Z p2)
(+ 3 0))))
((eq 'B p1)
(cond ((eq 'X p2)
(+ 1 0))
((eq 'Y p2)
(+ 2 3))
((eq 'Z p2)
(+ 3 6))))
((eq 'C p1)
(cond ((eq 'X p2)
(+ 1 6))
((eq 'Y p2)
(+ 2 0))
((eq 'Z p2)
(+ 3 3)))))))
(defun part-one (input)
(reduce '+ (mapcar #'calc-points-one (parse-rounds input))))
(defun calc-points-two (round)
(let* ((round (uiop:split-string round :separator " "))
(p1 (intern (first round)))
(p2 (intern (second round))))
(cond ((eq 'A p1)
(cond ((eq 'X p2)
(+ 3 0))
((eq 'Y p2)
(+ 1 3))
((eq 'Z p2)
(+ 2 6))))
((eq 'B p1)
(cond ((eq 'X p2)
(+ 1 0))
((eq 'Y p2)
(+ 2 3))
((eq 'Z p2)
(+ 3 6))))
((eq 'C p1)
(cond ((eq 'X p2)
(+ 2 0))
((eq 'Y p2)
(+ 3 3))
((eq 'Z p2)
(+ 1 6)))))))
(defun part-two (input)
(reduce '+ (mapcar #'calc-points-two (parse-rounds input))))
+2500
View File
File diff suppressed because it is too large Load Diff