aboutsummaryrefslogtreecommitdiff
path: root/aoc2021/day-02/day-02.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 /aoc2021/day-02/day-02.rkt
parent6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff)
downloadgleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz
gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip
sorting by language
Diffstat (limited to 'aoc2021/day-02/day-02.rkt')
-rw-r--r--aoc2021/day-02/day-02.rkt24
1 files changed, 0 insertions, 24 deletions
diff --git a/aoc2021/day-02/day-02.rkt b/aoc2021/day-02/day-02.rkt
deleted file mode 100644
index 0bd0c3d..0000000
--- a/aoc2021/day-02/day-02.rkt
+++ /dev/null
@@ -1,24 +0,0 @@
-#lang racket
-(require advent-of-code
- threading
- algorithms)
-
-(define motion-data
- (~> (open-aoc-input (find-session) 2021 2 #:cache (string->path "./cache"))
- (port->list read _)
- (chunks-of _ 2)))
-
-;; part 1
-(for/fold ([depth 0] [position 0] #:result (* depth position)) ([motion (in-list motion-data)])
- (match motion
- [(list 'forward x) (values depth (+ position x))]
- [(list 'up x) (values (- depth x) position)]
- [(list 'down x) (values (+ depth x) position)]))
-
-;; part 2
-(for/fold ([aim 0] [depth 0] [position 0] #:result (* depth position))
- ([motion (in-list motion-data)])
- (match motion
- [(list 'forward x) (values aim (+ depth (* aim x)) (+ position x))]
- [(list 'up x) (values (- aim x) depth position)]
- [(list 'down x) (values (+ aim x) depth position)]))