day 17: minor despaghetti
This commit is contained in:
parent
357a58b55f
commit
a0bf7d0039
9
17.rkt
9
17.rkt
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(struct pt [x y z w] #:transparent)
|
(struct pt [x y z w] #:transparent)
|
||||||
(define pt-getters (list pt-x pt-y pt-z pt-w))
|
(define pt-getters (list pt-x pt-y pt-z pt-w))
|
||||||
|
(define origin (pt 0 0 0 0))
|
||||||
|
|
||||||
(define (pt+ . args)
|
(define (pt+ . args)
|
||||||
(for/fold ([ans (pt 0 0 0 0)]) ([x (in-list args)])
|
(for/fold ([ans (pt 0 0 0 0)]) ([x (in-list args)])
|
||||||
|
@ -21,13 +22,7 @@
|
||||||
(pt x y z w)))
|
(pt x y z w)))
|
||||||
|
|
||||||
(define nearby/4d
|
(define nearby/4d
|
||||||
(for*/list ([x (in-range -1 2)]
|
(for/list ([pt (in-pts origin origin #t)] #:unless (equal? pt origin)) pt))
|
||||||
[y (in-range -1 2)]
|
|
||||||
[z (in-range -1 2)]
|
|
||||||
[w (in-range -1 2)]
|
|
||||||
#:unless (and (zero? x) (zero? y) (zero? z) (zero? w)))
|
|
||||||
(pt x y z w)))
|
|
||||||
|
|
||||||
(define nearby/3d (filter #{zero? (pt-w %)} nearby/4d))
|
(define nearby/3d (filter #{zero? (pt-w %)} nearby/4d))
|
||||||
|
|
||||||
(define (calc-bounds world)
|
(define (calc-bounds world)
|
||||||
|
|
Loading…
Reference in New Issue