Initial commit
This commit is contained in:
commit
53da572ca6
43
.gitignore
vendored
Normal file
43
.gitignore
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
|
||||
# network security
|
||||
/network-security.data
|
||||
13
day01/day01.lisp
Normal file
13
day01/day01.lisp
Normal file
@ -0,0 +1,13 @@
|
||||
(defun calories-per-elf (input)
|
||||
(mapcar (lambda (x) (cl-ppcre:split "\\s+" x))
|
||||
(cl-ppcre:split "\\n\\n" (uiop:read-file-string input))))
|
||||
|
||||
(defun parse-strings-and-sum (cals-per-elf)
|
||||
(reduce '+ (mapcar #'parse-integer cals-per-elf)))
|
||||
|
||||
(defun part-one (input)
|
||||
(apply #'max (mapcar #'parse-strings-and-sum
|
||||
(calories-per-elf input))))
|
||||
|
||||
(defun part-two (input)
|
||||
(reduce '+ (subseq (sort (mapcar #'parse-strings-and-sum (calories-per-elf input)) '>) 0 3)))
|
||||
2251
day01/input
Normal file
2251
day01/input
Normal file
File diff suppressed because it is too large
Load Diff
60
day02/day02.lisp
Normal file
60
day02/day02.lisp
Normal 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
day02/input
Normal file
2500
day02/input
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user