master
Matthew Butterick 4 years ago
parent 2f92fcc170
commit 4f58128ddc

@ -0,0 +1,18 @@
#lang br
(require racket/file srfi/13 rackunit)
(define (seat-id seat)
(for/sum ([(c i) (in-indexed (string-reverse seat))]
#:when (memv c '(#\R #\B)))
(arithmetic-shift 1 i)))
(define seat-ids (map seat-id (file->lines "05.rktd")))
(check-equal? (apply max seat-ids) 915)
(check-equal?
(for/first ([first (sort seat-ids <)]
[second (cdr (sort seat-ids <))]
#:when (= 2 (- second first)))
(sub1 second))
699)

@ -0,0 +1,869 @@
FFFFBBBRLR
BFBBFBFRRR
FFBFBBFRRL
BFBFBBFRRR
BFBBFFFLLR
FFFBFFFRRL
BFFBFFFLLL
BFFBFFFRRL
FFBBFBBLRR
BBFBBFBLLL
BFFFFBFRRL
BFFFBFBLLR
BBFFBFFRLR
BFBFBBFLLR
BBFBFBFRLR
BBFFBFFRRL
FBFFFBFLRL
BFFFBBFLLL
FBFFFFFLLR
FBFFFBFLRR
BFBFBFBLLR
BFBBBFFRLR
FBBBFFFLRR
BBBFFFFLRL
FBBFFFFLRR
BFFFBFBRLL
BFBBBBBLLL
BBFBFBFRLL
FFBFBBBRRR
FBBBFBBLRL
BFFBFBFRRR
BBFFBFBRLR
FBFFFFBRRR
FBFBBFBLRR
BBBFFFBLLL
FBFFBBFLLL
FBFBBBBLRL
BFBFBFBLRL
BFBFFBFLLL
FBBBBFFRRR
BFBFFBBRLL
FFBFBBFLRL
BFBBBFFLLR
FBFFBBBLRL
BFBBBFFRRR
FFFBFBBLLR
FFBBFFBRLL
BFFBBFBRLL
BFBBFBBLRR
BFFFFBBRRL
FFFBBFFLLR
FBFBBFFLRL
FFFBFBBRLL
FBBBFBFLRL
BFFFBBBRLL
FFBFBFBLLR
FBFBFFBLRL
FBBFBFBLLL
FFFBBBBLLL
BFFBBBFRRL
BFFFBBBRRL
BBFBBBBRLR
FFBFBBBRRL
FFFBFFFLRR
BFFFBBBLRL
BFBFFBBRRL
BBBFFFBLRL
FFFBF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