(asdf:load-system :adventofcode2020) (in-package #:adventofcode2020) (defun calc-seat (seat-spec) (loop with len = (1- (length seat-spec)) for c across seat-spec for i downfrom len summing (if (or (char= c #\R) (char= c #\B)) (ash 1 i) 0))) (day 05 input (let* ((lines (list-from input)) (seat-ids (-<>> lines (mapcar #'calc-seat) (sort <> #'>)))) (part1 (first seat-ids)) (part2 (loop for big in seat-ids for small in (cdr seat-ids) when (= small (- big 2)) return (1+ small))))) (def-suite day05) (in-suite day05) (test calc-seats (is (equal '(357 567 119 820) (mapcar #'calc-seat '("FBFBBFFRLR" "BFFFBBFRRR" "FFFBBBFRRR" "BBFFBBFRLL"))))) (run! 'day05)