🎄⌨️ Advent of Code 2018

Check-in [96ef01]
Overview
Comment:fix backwardity
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | day15
Files: files | file ages | folders
SHA3-256: 96ef0187bfad6191904d004fa7f1119574bca46af81a1f9caab297ff6e6db8ea
User & Date: joel on 2019-11-27 19:07:46
Other Links: branch diff | manifest | tags
Context
2019-11-28
16:08
evolution check-in: 722424 user: joel tags: day15
2019-11-27
19:07
fix backwardity check-in: 96ef01 user: joel tags: day15
2019-11-26
23:01
Refine what we got check-in: e94fa4 user: joel tags: day15
Changes

Modified day15.rkt from [124443] to [266d98].

99
100
101
102
103
104
105
106
107


108
109
110
111
112
113
114
115
116
117




118
119
120
121
122
123
124
99
100
101
102
103
104
105


106
107
108
109
110
111
112





113
114
115
116
117
118
119
120
121
122
123







-
-
+
+





-
-
-
-
-
+
+
+
+







                  [else (cons ch lst)])))))

;; 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)
  (cond [(posn? pos)
         (~> (neighbor-coords world pos)