From c5ac16de3ec4eb60580b1a4b6ea6fc0c63d75466 Mon Sep 17 00:00:00 2001 From: Jack Kinsey Date: Sat, 5 Dec 2020 18:57:39 -0500 Subject: [PATCH] Add day 05 --- res/day05 | 843 +++++++++++++++++++++++++++++++++++++++++++++++++ src/day05.lisp | 40 +++ 2 files changed, 883 insertions(+) create mode 100644 res/day05 create mode 100644 src/day05.lisp diff --git a/res/day05 b/res/day05 new file mode 100644 index 0000000..e4a4418 --- /dev/null +++ b/res/day05 @@ -0,0 +1,843 @@ +BBFFBBFLRL +BFFFBBBRLL +FFBBFFFLLR +FBFBFFBRRL +FBBBBBFLLR +BFBBFFBLRL +BFBBFBFRRL +BFBFFBBLLL +BFBFFFBRLL +FFFBFBFLLL +BFBFBBBLRR +BFBBFBFRLR +FFFBBBBLLL +BFFBFFFLLR +BBFBFBBLLL +BFFFBBBRRR +FBBFFBFRLR +BFFFFBBRRR +FFBFFFBLLL +BBFFFFBRRL +BFFFFFBLRL +BBFBBBBLRR +FBBFBFBRLR +BFBFFFBRRL +BBFFFBBLRR +BBFBBFFRRR +FFBBFBBLLR +BFBFFFBLLL +BFFBBBBLRR +FBBBBFBLRL +BBFBFBFRRR +BFFFBFBLRR +BBFFFBBRRL +FFBFBBBRLR +BFFFBBBRLR +FBBBBFBRLL +BFBBBBFLLR +BFFBFBBRRR +BFBFFBBLRL +FFFBBFBRLR +FFBBBBFLLL +BFBFBBFLLR +BBFBBBFRLR +BFFBBBBRLL +FFBFFFBLRL +FBFFBBFRLL +BFBBFFFLLR +FBFBBFFLRL +FFFBBBFLRR +BBFBBFFLRR +BFBBFBFLLR +BFFBFBFRRR +BFBBFFFRLR +BFFBFBBLRR +FBFBBBBLLL +FBFBFFFLRL +FFBFBBBRLL +FFBFBBBLRR +BFFBFBFLLL +FBBFFBBRRR +FBFBFBFLRR +FBBFBBBRRL +BFFBBBBRLR +FFFBFFBRRR +BFFFFBFRRR +FBBFBFFRLL +FFBBFBFRLL +BBFFBBBRLR +FFBBF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BFFFFRLL +BFBFBFBRRL +FBFFFBFLLL +FFBFFBBLLL +BFFBBFBRLR +FFFBFBBLRL +BFBBFFBRRR +FBFFBFBRRR +BFBFBBFRRL +FBBBFBBLLL +BBFBFBFRRL +BFFBFBBRRL +BBFBBBFLLL +FFFBFFBRLR +BFFFBBBLRR +FBFFFFBLLL +FFFBBBFRLL +FBFBBFFLRR +FBFBFFFLLL +BFBFBFFRLL +FBFBBFFRRL +FBBBBBBLLR +BFBFBFFRRR +FBFFBBBLRR +FBFFBFFRLR +FBFBBBBLRR +BBFFBFBLRL +FBBFBFFRLR +FBBFFFBLRR +BFBFBFFRRL diff --git a/src/day05.lisp b/src/day05.lisp new file mode 100644 index 0000000..ee60cd2 --- /dev/null +++ b/src/day05.lisp @@ -0,0 +1,40 @@ +(asdf:load-system :adventofcode2020) +(in-package #:adventofcode2020) + +(defun calc-seat (seat-spec) + (let ((row (string-right-trim "RL" seat-spec)) + (col (string-left-trim "FB" seat-spec)) + (convert-to-int + (lambda (str one) + (loop with len = (1- (length str)) + for c across str + for i downfrom len + summing (if (char= c one) + (ash 1 i) 0))))) + (mapcar convert-to-int (list row col) '(#\B #\R)))) + +(defun calc-seat-id (row-col) + (destructuring-bind (row col) row-col + (+ (* row 8) col))) + +(day 05 input + (let* ((lines (list-from input)) + (seat-ids (-<>> lines + (mapcar (compose #'calc-seat-id #'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 + '((44 5) (70 7) (14 7) (102 4)) + (mapcar #'calc-seat '("FBFBBFFRLR" "BFFFBBFRRR" + "FFFBBBFRRR" "BBFFBBFRLL"))))) + +(run! 'day05) -- 2.38.5