aboutsummaryrefslogtreecommitdiff
path: root/aoc2023-other/day-08/day-08.rkt
diff options
context:
space:
mode:
authorHunky Jimpjorps <thechairman@thechairman.info>2024-02-02 17:05:12 -0500
committerHunky Jimpjorps <thechairman@thechairman.info>2024-02-02 17:05:12 -0500
commit48e35ad3b0b0c62f936784e4aca70b17c3b0e3f9 (patch)
treef59a13e0b5e80ab925220b4488c6e36b1bec660a /aoc2023-other/day-08/day-08.rkt
parent87e9ab25ff70e215b537939a4bc23ab101f41dbe (diff)
downloadgleam_aoc-48e35ad3b0b0c62f936784e4aca70b17c3b0e3f9.tar.gz
gleam_aoc-48e35ad3b0b0c62f936784e4aca70b17c3b0e3f9.zip
renaming
Diffstat (limited to 'aoc2023-other/day-08/day-08.rkt')
-rw-r--r--aoc2023-other/day-08/day-08.rkt36
1 files changed, 0 insertions, 36 deletions
diff --git a/aoc2023-other/day-08/day-08.rkt b/aoc2023-other/day-08/day-08.rkt
deleted file mode 100644
index 06daafa..0000000
--- a/aoc2023-other/day-08/day-08.rkt
+++ /dev/null
@@ -1,36 +0,0 @@
-#lang racket
-
-(require advent-of-code
- threading)
-
-(struct exits (left right) #:transparent)
-
-(match-define (list raw-directions raw-maze)
- (~> (fetch-aoc-input (find-session) 2023 8 #:cache #true) (string-split "\n\n")))
-
-(define directions (string->list raw-directions))
-
-(define maze
- (for/hash ([line (in-list (string-split raw-maze "\n"))])
- (match (regexp-match #rx"(...) = \\((...), (...)\\)" line)
- [(list _ name left right) (values name (exits left right))])))
-
-(define (to-next-node start end dirs maze)
- (for/fold ([current start]
- [acc 0]
- #:result acc)
- ([dir (in-cycle dirs)])
- #:break (string-suffix? current end)
- (define node (hash-ref maze current))
- (case dir
- [(#\L) (values (exits-left node) (add1 acc))]
- [(#\R) (values (exits-right node) (add1 acc))])))
-
-;; part 1
-(to-next-node "AAA" "ZZZ" directions maze)
-
-;; part 2
-(for/lists (ns #:result (apply lcm ns))
- ([start (in-list (hash-keys maze))]
- #:when (string-suffix? start "A"))
- (to-next-node start "Z" directions maze))