master
4903000 4 years ago
parent 96a81894e2
commit c7e72e49e0

@ -212,3 +212,22 @@
(time (progn (print (solve-5-1 (copy-seq data)))
(solve-5-2 data)
(print p1-answer)))))
(defun read-forms (stream)
(loop for line = (read-line stream nil)
while (and line (not (string= line "")))
collect line))
(defun read-6 (file)
(with-open-file (stream file)
(loop while (peek-char nil stream nil)
collect (read-forms stream))))
(defun solve-6-1 (data)
(reduce (lambda (x y) (+ (if (consp x) (length x) x) (length y)))
(map 'list (lambda (form) (remove-duplicates (apply #'concatenate 'list form))) data)))
(defun solve-6-2 (data)
(length (mapcan (lambda (entry)
(reduce #'intersection (map 'list (lambda (l) (coerce l 'list)) entry)))
data)))

Loading…
Cancel
Save