diff options
author | HJ <thechairman@thechairman.info> | 2023-12-15 08:37:45 -0500 |
---|---|---|
committer | HJ <thechairman@thechairman.info> | 2023-12-15 08:37:45 -0500 |
commit | c92cd5ba942286f90a75c4121e0035e078def2fe (patch) | |
tree | e1fa3d3acc4d7c4647028e6a4d06591a20797ae2 /aoc2023-other/day-15/day-15.rkt | |
parent | 7a6795ab46a745bd841272a400213a4c0162437d (diff) | |
download | gleam_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.rkt | 6 |
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)])) |