aboutsummaryrefslogtreecommitdiff
path: root/aoc2023-racket/day-06/day-06.rkt
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
committerH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
commit8777ff071f7bb37631baa7b6717ad29961e50911 (patch)
tree6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2023-racket/day-06/day-06.rkt
parent6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff)
downloadgleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz
gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip
sorting by language
Diffstat (limited to 'aoc2023-racket/day-06/day-06.rkt')
-rw-r--r--aoc2023-racket/day-06/day-06.rkt32
1 files changed, 0 insertions, 32 deletions
diff --git a/aoc2023-racket/day-06/day-06.rkt b/aoc2023-racket/day-06/day-06.rkt
deleted file mode 100644
index 53ca9ee..0000000
--- a/aoc2023-racket/day-06/day-06.rkt
+++ /dev/null
@@ -1,32 +0,0 @@
-#lang racket
-
-(require advent-of-code
- threading)
-
-(match-define (list times distances)
- (~> (open-aoc-input (find-session) 2023 6 #:cache #true) port->lines))
-
-;; part 1
-(define get-numbers (λ~> string-split (map string->number _) rest))
-(define (find-bound race-time dist button-time step)
- (if (< dist (* button-time (- race-time button-time)))
- button-time
- (find-bound race-time dist (+ step button-time) step)))
-
-(define (lower-bound rtime dist)
- (find-bound rtime dist 1 1))
-(define (upper-bound rtime dist)
- (find-bound rtime dist rtime -1))
-
-(for/fold ([acc 1])
- ([race-time (in-list (get-numbers times))]
- [distance (in-list (get-numbers distances))])
- (* acc (add1 (- (upper-bound race-time distance) (lower-bound race-time distance)))))
-
-;; part 2
-
-(define unkern (λ~>> get-numbers (apply ~a) string->number))
-(define big-time (unkern times))
-(define big-distance (unkern distances))
-
-(add1 (- (upper-bound big-time big-distance) (lower-bound big-time big-distance)))