diff --git a/src/08.rkt b/src/08.rkt index eaff747..e9d9614 100644 --- a/src/08.rkt +++ b/src/08.rkt @@ -7,7 +7,7 @@ (for/list ([entry (problem-input 8)]) (match-let ([(list patterns outputs) (string-split entry " | ")]) (list (map string->list (string-words patterns)) - (map #{sort (string->list %) charlist (string-words outputs)))))) (define part1 (~>> input @@ -15,7 +15,7 @@ (map #{count #{(or/c 2 3 4 7) (length %)} %}) sum)) -(define (config patterns) +(define ((config patterns) segs) (define (digit segments) (findf #{= (length %) segments} patterns)) (define (digits segments) @@ -30,22 +30,23 @@ (define six (set-union (set-subtract eight one) sixes)) (define zero (set-union (set-subtract eight three) (set-subtract eight four) one)) (define two (set-union (set-subtract zero sixes) fives)) - (hash (sort zero char> (second entry) - (map #{hash-ref mapping %}) + (map mapping) list->string string->number))))