Initial commit
This commit is contained in:
@@ -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
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user