1 (asdf:load-system :adventofcode2020)
2 (in-package #:adventofcode2020)
3 (named-readtables:in-readtable :adventofcode2020)
5 (defun count-answers (join ans-list)
7 (mapcar λ(map 'list #'identity _))
8 (reduce λ(funcall join _0 _1 :test #'char=))
12 (let ((answer-groups (-<>> (list-from input)
13 (split-sequence "" <> :test #'string=)))
14 (disjunction (curry #'count-answers #'union))
15 (conjunction (curry #'count-answers #'intersection) ))
16 (part1 (->> answer-groups (mapcar disjunction) (reduce #'+)))
17 (part2 (->> answer-groups (mapcar conjunction) (reduce #'+)))))
22 (test count-answers-disj
25 (mapcar (curry #'count-answers #'union)
26 '(("abc") ("a" "b" "c") ("ab" "ac")
27 ("a" "a" "a" "a") ("b"))))))
29 (test count-answers-conj
32 (mapcar (curry #'count-answers #'intersection)
33 '(("abc") ("a" "b" "c") ("ab" "ac")
34 ("a" "a" "a" "a") ("b"))))))