Index: day15.rkt ================================================================== --- day15.rkt +++ day15.rkt @@ -101,22 +101,21 @@ ;; Is point p inside grid g? Film at 11 (define (inside-grid? g p) (match-define (posn px py) p) (and (>= px 0) (>= py 0) - (< px (grid-rows g)) - (< py (grid-cols g)))) + (< px (grid-cols g)) + (< py (grid-rows g)))) ;; Get a list of a positions neighboring points, ensuring none are out of bounds (define (neighbor-coords g pos) (match-define (posn x y) pos) (filter (curry inside-grid? g) - (map (lambda (lst) (apply posn lst)) - `((,(- x 1) ,y) - (,x ,(+ y 1)) - (,(+ x 1) ,y) - (,x ,(- y 1)))))) + (list (posn (- x 1) y) + (posn x (+ y 1)) + (posn (+ x 1) y) + (posn x (- y 1))))) ;; Get all the EMPTY neighboring points of a given spot OR list of spots. ;; If a (listof posn?) is passed, ensures the returned list does not include ;; any of the original positions. (define (free-neighbors-at world pos)