From c92cd5ba942286f90a75c4121e0035e078def2fe Mon Sep 17 00:00:00 2001 From: HJ Date: Fri, 15 Dec 2023 08:37:45 -0500 Subject: day 15 racket complete --- aoc2023-other/day-15/day-15.rkt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'aoc2023-other/day-15/day-15.rkt') diff --git a/aoc2023-other/day-15/day-15.rkt b/aoc2023-other/day-15/day-15.rkt index 59042e6..d049565 100644 --- a/aoc2023-other/day-15/day-15.rkt +++ b/aoc2023-other/day-15/day-15.rkt @@ -32,10 +32,10 @@ (define (focusing-power boxes) (for*/sum ([(box-number lenses) (in-hash boxes)] [(lens order) (in-indexed lenses)]) - (match-define (cons _ focal) lens) - (* (add1 box-number) (add1 order) (string->number focal)))) + (* (add1 box-number) (add1 order) (cdr lens)))) (for/fold ([boxes (hash)] #:result (focusing-power boxes)) ([code (in-list input)]) (match code - [(regexp #rx"(.*)=(.*)" (list _ label focal)) (insert-lens boxes label focal)] + [(regexp #rx"(.*)=(.*)" (list _ label (app string->number focal))) + (insert-lens boxes label focal)] [(regexp #rx"(.*)-" (list _ label)) (remove-lens boxes label)])) -- cgit v1.2.3