aboutsummaryrefslogtreecommitdiff
path: root/aoc2023-other/day-15/day-15.rkt
diff options
context:
space:
mode:
authorHJ <thechairman@thechairman.info>2023-12-15 08:37:45 -0500
committerHJ <thechairman@thechairman.info>2023-12-15 08:37:45 -0500
commitc92cd5ba942286f90a75c4121e0035e078def2fe (patch)
treee1fa3d3acc4d7c4647028e6a4d06591a20797ae2 /aoc2023-other/day-15/day-15.rkt
parent7a6795ab46a745bd841272a400213a4c0162437d (diff)
downloadgleam_aoc-c92cd5ba942286f90a75c4121e0035e078def2fe.tar.gz
gleam_aoc-c92cd5ba942286f90a75c4121e0035e078def2fe.zip
day 15 racket complete
Diffstat (limited to 'aoc2023-other/day-15/day-15.rkt')
-rw-r--r--aoc2023-other/day-15/day-15.rkt6
1 files changed, 3 insertions, 3 deletions
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)]))