1 (asdf:load-system :adventofcode2020)
2 (in-package #:adventofcode2020)
4 (defun calc-seat (seat-spec)
5 (let ((row (string-right-trim "RL" seat-spec))
6 (col (string-left-trim "FB" seat-spec))
9 (loop with len = (1- (length str))
12 summing (if (char= c one)
14 (mapcar convert-to-int (list row col) '(#\B #\R))))
16 (defun calc-seat-id (row-col)
17 (destructuring-bind (row col) row-col
21 (let* ((lines (list-from input))
23 (mapcar (compose #'calc-seat-id #'calc-seat))
25 (part1 (first seat-ids))
26 (part2 (loop for big in seat-ids
27 for small in (cdr seat-ids)
28 when (= small (- big 2))
36 '((44 5) (70 7) (14 7) (102 4))
37 (mapcar #'calc-seat '("FBFBBFFRLR" "BFFFBBFRRR"
38 "FFFBBBFRRR" "BBFFBBFRLL")))))