aboutsummaryrefslogtreecommitdiff
path: root/2022/day-12/day-12.rkt
diff options
context:
space:
mode:
authorHunky Jimpjorps <thechairman@thechairman.info>2022-12-13 01:19:05 -0500
committerHunky Jimpjorps <thechairman@thechairman.info>2022-12-13 01:19:05 -0500
commitfd3d1f61531f5c48125b822ab3bd2cdc65fc9254 (patch)
tree488275bf0b9ff8d73821bb2a7f3be7bf82e2bcaa /2022/day-12/day-12.rkt
parent80fbd3beb20303dc5be6272a6e6e14939d5d94d0 (diff)
parentb70835069c1bcc8a9ca316b1795de3bfd6d6f12e (diff)
downloadgleam_aoc-fd3d1f61531f5c48125b822ab3bd2cdc65fc9254.tar.gz
gleam_aoc-fd3d1f61531f5c48125b822ab3bd2cdc65fc9254.zip
Merge branch 'main' of https://github.com/hunkyjimpjorps/AdventOfCode into main
Diffstat (limited to '2022/day-12/day-12.rkt')
-rw-r--r--2022/day-12/day-12.rkt13
1 files changed, 7 insertions, 6 deletions
diff --git a/2022/day-12/day-12.rkt b/2022/day-12/day-12.rkt
index 9120468..5e0c365 100644
--- a/2022/day-12/day-12.rkt
+++ b/2022/day-12/day-12.rkt
@@ -35,11 +35,12 @@
(list p neighbor))))
;; part 1
-(match-define-values (distances _) (dijkstra paths (hash-ref special-points 'start)))
-(hash-ref distances (hash-ref special-points 'end))
+(time (match-define-values (distances _) (bfs paths (hash-ref special-points 'start)))
+ (hash-ref distances (hash-ref special-points 'end)))
;; part 2
-(for/lists (lengths #:result (apply min lengths))
- ([start (in-list (hash-keys terrain-mesh))] #:when (= 0 (hash-ref terrain-mesh start)))
- (match-define-values (distances _) (dijkstra paths start))
- (hash-ref distances (hash-ref special-points 'end)))
+(time (for/lists
+ (lengths #:result (apply min lengths))
+ ([start (in-list (hash-keys terrain-mesh))] #:when (= 0 (hash-ref terrain-mesh start)))
+ (match-define-values (distances _) (bfs paths start))
+ (hash-ref distances (hash-ref special-points 'end))))