aboutsummaryrefslogtreecommitdiff
path: root/aoc2020/day-05
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
committerH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
commit8777ff071f7bb37631baa7b6717ad29961e50911 (patch)
tree6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2020/day-05
parent6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff)
downloadgleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz
gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip
sorting by language
Diffstat (limited to 'aoc2020/day-05')
-rw-r--r--aoc2020/day-05/day-05.rkt35
1 files changed, 0 insertions, 35 deletions
diff --git a/aoc2020/day-05/day-05.rkt b/aoc2020/day-05/day-05.rkt
deleted file mode 100644
index bd89ede..0000000
--- a/aoc2020/day-05/day-05.rkt
+++ /dev/null
@@ -1,35 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt"
- threading)
-
-(define tickets
- (for/list ([l (in-lines (open-day 5 2020))])
- (~>> l (regexp-match #px"(.{7})(.{3})") rest)))
-
-(define (find-place str min-p max-p l r)
- (if (string=? "" str)
- min-p
- (let ([p-range (/ (add1 (- max-p min-p)) 2)] [c (substring str 0 1)])
- (cond
- [(string=? c l) (find-place (substring str 1) min-p (- max-p p-range) l r)]
- [(string=? c r) (find-place (substring str 1) (+ min-p p-range) max-p l r)]))))
-
-(define (find-row str)
- (find-place str 0 127 "F" "B"))
-(define (find-col str)
- (find-place str 0 7 "L" "R"))
-
-(define (ticket-id t)
- (let ([row (find-row (first t))] [col (find-col (second t))]) (+ col (* 8 row))))
-
-;; part 1
-(define occupied-seats
- (~>> (for/list ([t (in-list tickets)])
- (ticket-id t))))
-
-(apply max occupied-seats)
-
-;; part 2
-(set-first (set-subtract
- (list->set (inclusive-range (apply min occupied-seats) (apply max occupied-seats)))
- (list->set occupied-seats)))