master
Matthew Butterick 7 years ago
parent 4b8627131a
commit 18628e6092

@ -37,11 +37,12 @@
(define vals (make-hash))
(define (neighbor-sum n)
(define c (nth-coordinate n))
(define neighbor-offsets '(1 1+i +i -1+i -1 -1-1i -i 1-i))
(hash-ref! vals c (λ () (if (= c 0)
1
(for/sum ([n (in-list neighbor-offsets)])
(hash-ref vals (+ c n) 0))))))
(for*/sum ([h (in-list '(-1 0 1))]
[v (in-list '(-1 0 1))])
(define neighbor (+ h (* +i v)))
(hash-ref vals (+ c neighbor) 0))))))
(define (larger-sum x)
(for*/first ([n (in-naturals 1)]