|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
;;;; AoC 2020
|
|
|
|
|
|
|
|
|
|
;;; Day 1
|
|
|
|
|
|
|
|
|
|
(defun read-1 (file)
|
|
|
|
|
(with-open-file (stream file)
|
|
|
|
|
(loop for line = (read-line stream nil)
|
|
|
|
@ -32,6 +34,8 @@
|
|
|
|
|
(print (solve-1-1 data target))
|
|
|
|
|
(print (solve-1-2 data target)))))
|
|
|
|
|
|
|
|
|
|
;;; Day 2
|
|
|
|
|
|
|
|
|
|
(defstruct password
|
|
|
|
|
(pchar)
|
|
|
|
|
(prange)
|
|
|
|
@ -74,6 +78,8 @@
|
|
|
|
|
(time (progn (print (%solve-2 data #'%solve-2-1))
|
|
|
|
|
(print (%solve-2 data #'%solve-2-2))))))
|
|
|
|
|
|
|
|
|
|
;;; Day 3
|
|
|
|
|
|
|
|
|
|
(defun read-3 (file)
|
|
|
|
|
(with-open-file (stream file)
|
|
|
|
|
(let ((temp-map (loop for line = (read-line stream nil)
|
|
|
|
@ -116,6 +122,8 @@
|
|
|
|
|
(print (solve-3-1 '(1 3) data))
|
|
|
|
|
(print (solve-3-2 '((1 1) (1 3) (1 5) (1 7) (2 1)) data)))))
|
|
|
|
|
|
|
|
|
|
;;; Day 4
|
|
|
|
|
|
|
|
|
|
(defvar *passport-fields* (list "byr" "iyr" "eyr" "hgt" "hcl" "ecl" "pid" "cid"))
|
|
|
|
|
(defvar *passport-rules-broken* (list nil nil nil nil nil nil nil (lambda (n) (declare (ignore n)) t)))
|
|
|
|
|
(defvar *passport-rules* nil)
|
|
|
|
@ -184,6 +192,8 @@
|
|
|
|
|
#\0 (elt bits 0) string))
|
|
|
|
|
:radix 2))
|
|
|
|
|
|
|
|
|
|
;;; Day 5
|
|
|
|
|
|
|
|
|
|
(defun read-5 (file)
|
|
|
|
|
(with-open-file (stream file)
|
|
|
|
|
(loop for line = (read-line stream nil)
|
|
|
|
@ -213,6 +223,8 @@
|
|
|
|
|
(solve-5-2 data)
|
|
|
|
|
(print p1-answer)))))
|
|
|
|
|
|
|
|
|
|
;;; Day 6
|
|
|
|
|
|
|
|
|
|
(defun read-forms (stream)
|
|
|
|
|
(loop for line = (read-line stream nil)
|
|
|
|
|
while (and line (not (string= line "")))
|
|
|
|
|