aboutsummaryrefslogtreecommitdiff
path: root/2021/day-02
diff options
context:
space:
mode:
authorHunky Jimpjorps <thechairman@thechairman.info>2022-11-26 01:43:33 -0500
committerHunky Jimpjorps <thechairman@thechairman.info>2022-11-26 01:43:33 -0500
commitfeccf3f6f0a806b3317d1f399e3e8b42945c4f09 (patch)
treebf15ce045d1106c1b7f7de30c27540f40d0bf947 /2021/day-02
parent8b624fe7d2751337b1f16830cc9c041df73e99e7 (diff)
downloadgleam_aoc-feccf3f6f0a806b3317d1f399e3e8b42945c4f09.tar.gz
gleam_aoc-feccf3f6f0a806b3317d1f399e3e8b42945c4f09.zip
using raco fmt, replacing missing dependency
Diffstat (limited to '2021/day-02')
-rw-r--r--2021/day-02/day-02.rkt31
1 files changed, 8 insertions, 23 deletions
diff --git a/2021/day-02/day-02.rkt b/2021/day-02/day-02.rkt
index dbd1275..0bd0c3d 100644
--- a/2021/day-02/day-02.rkt
+++ b/2021/day-02/day-02.rkt
@@ -9,31 +9,16 @@
(chunks-of _ 2)))
;; part 1
-(for/fold ([depth 0]
- [position 0]
- #:result (* depth position))
- ([motion (in-list motion-data)])
+(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)]))
+ [(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))
+(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)])) \ No newline at end of file
+ [(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)]))