1
0
Fork 0

Day 08: Use different deduction.

This commit is contained in:
Jonathan Chan 2021-12-07 22:26:26 -08:00 committed by Jonathan Chan
parent 91e6c394d5
commit 466c59e52b
1 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@
(for/list ([entry (problem-input 8)]) (for/list ([entry (problem-input 8)])
(match-let ([(list patterns outputs) (string-split entry " | ")]) (match-let ([(list patterns outputs) (string-split entry " | ")])
(list (map string->list (string-words patterns)) (list (map string->list (string-words patterns))
(map ( #{sort % char<?} string->list) (string-words outputs)))))) (map #{sort (string->list %) char<?} (string-words outputs))))))
(define part1 (define part1
(~>> input (~>> input
@ -28,14 +28,14 @@
(set-first (set-subtract seven one))) (set-first (set-subtract seven one)))
(define bottom (define bottom
(set-first (set-subtract (apply set-intersect fives) four `(,top)))) (set-first (set-subtract (apply set-intersect fives) four `(,top))))
(define middle
(set-first (set-subtract (apply set-intersect fives) `(,top ,bottom))))
(define top-left (define top-left
(set-first (set-subtract (apply set-intersect sixes) one `(,top ,bottom)))) (set-first (set-subtract four one `(,middle))))
(define bottom-right (define bottom-right
(set-first (set-subtract (apply set-intersect sixes) `(,top ,bottom ,top-left)))) (set-first (set-subtract (apply set-intersect sixes) `(,top ,bottom ,top-left))))
(define top-right (define top-right
(set-first (set-remove one bottom-right))) (set-first (set-remove one bottom-right)))
(define middle
(set-first (set-subtract four one `(,top-left))))
(define bottom-left (define bottom-left
(set-first (set-subtract eight `(,top ,bottom ,top-left ,top-right ,bottom-right ,middle)))) (set-first (set-subtract eight `(,top ,bottom ,top-left ,top-right ,bottom-right ,middle))))
(hash (sort one char<?) #\1 (hash (sort one char<?) #\1