From 4627530968413cde4b581c7df8d6bdc9f7f4b14b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 7 Dec 2020 08:48:05 -0700 Subject: [PATCH] Solve AOC day 5 part 2 --- projects/aoc/src/year2020/Solutions.kiss | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/projects/aoc/src/year2020/Solutions.kiss b/projects/aoc/src/year2020/Solutions.kiss index 7c6f6420..9e38b2f1 100644 --- a/projects/aoc/src/year2020/Solutions.kiss +++ b/projects/aoc/src/year2020/Solutions.kiss @@ -48,9 +48,19 @@ (assert (= 250 (Passports.countValidPassports (new Stream "src/year2020/inputs/day4-1.txt")))) (assert (= 158 (Passports.countValidPassports (new Stream "src/year2020/inputs/day4-1.txt") "strict"))) - // TODO Day 5 + // Day 5 (assert (= 567 (Seating.seatId "BFFFBBFRRR"))) - (assert (= 947 (apply max (map (Util.readLines "src/year2020/inputs/day5-1.txt") Seating.seatId)))) + (let [:kiss.List seatIds (map (Util.readLines "src/year2020/inputs/day5-1.txt") Seating.seatId)] + (seatIds.sort (lambda [a b] (- a b))) + (assert (= 947 (nth seatIds -1))) + (deflocal &mut lastId -1) + (deflocal &mut myId -1) + (doFor id seatIds + (when (and (<= 0 lastId) !(= lastId (- id 1))) + (set myId (- id 1)) + (break)) + (set lastId id)) + (assert (= 636 myId))) // Day 6 (assert (= 6 (Customs.countAnyYes ["abcx" "abcy" "abcz"])))