aboutsummaryrefslogtreecommitdiff
path: root/2021/day-05
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-05
parent8b624fe7d2751337b1f16830cc9c041df73e99e7 (diff)
downloadgleam_aoc-feccf3f6f0a806b3317d1f399e3e8b42945c4f09.tar.gz
gleam_aoc-feccf3f6f0a806b3317d1f399e3e8b42945c4f09.zip
using raco fmt, replacing missing dependency
Diffstat (limited to '2021/day-05')
-rw-r--r--2021/day-05/day-05.rkt18
1 files changed, 6 insertions, 12 deletions
diff --git a/2021/day-05/day-05.rkt b/2021/day-05/day-05.rkt
index 49ce502..e568490 100644
--- a/2021/day-05/day-05.rkt
+++ b/2021/day-05/day-05.rkt
@@ -4,25 +4,20 @@
(define data
(for/list ([l (in-lines (open-aoc-input (find-session) 2021 5 #:cache (string->path "./cache")))])
- (~> l
- (string-replace " -> " ",")
- (string-split ",")
- (map string->number _))))
+ (~> l (string-replace " -> " ",") (string-split ",") (map string->number _))))
(define (trace-line! x y vec)
(define linear-coord (+ y (* 1000 x)))
- (vector-set! vec
- linear-coord
- (+ 1 (vector-ref vec linear-coord))))
+ (vector-set! vec linear-coord (+ 1 (vector-ref vec linear-coord))))
(define/match (orthogonal? coord-pair)
[((or (list n _ n _) (list _ n _ n))) #t]
[(_) #f])
-(define-values (orthogonal-lines diagonal-lines)
- (partition orthogonal? data))
+(define-values (orthogonal-lines diagonal-lines) (partition orthogonal? data))
-(define (dir a b) (if (< a b) 1 -1))
+(define (dir a b)
+ (if (< a b) 1 -1))
(define (trace-orthogonal! coord-pairs tracer result)
(for ([coord-pair (in-list coord-pairs)])
@@ -37,8 +32,7 @@
(define (trace-diagonal! coord-pairs tracer result)
(for ([coord-pair (in-list coord-pairs)])
(match-define (list x1 y1 x2 y2) coord-pair)
- (for ([x (inclusive-range x1 x2 (dir x1 x2))]
- [y (inclusive-range y1 y2 (dir y1 y2))])
+ (for ([x (inclusive-range x1 x2 (dir x1 x2))] [y (inclusive-range y1 y2 (dir y1 y2))])
(tracer x y result))))
;; part 1