No need to make it a macro
This commit is contained in:
parent
574c6ed158
commit
fc696060d4
26
2022.org
26
2022.org
|
@ -9103,19 +9103,19 @@ Consider your map; how many trees are visible from outside the grid?
|
|||
(puthash (cons m n) (plist-put cur-value direction value) vmap)
|
||||
vmap))
|
||||
|
||||
(defmacro advent/8/count-trees-from-edge ()
|
||||
''(let ((h (advent/8/height-at hmap m n))
|
||||
(vmap-update (apply-partially #'advent/8/update-vmap vmap m n))
|
||||
(max-vert (or (advent/8/max-height-at vmap (+ m (* -1 step)) n vprop) 0))
|
||||
(max-hor (or (advent/8/max-height-at vmap m (+ n (* -1 step)) hprop) 0))
|
||||
(max-heights (-non-nil (list
|
||||
(plist-get (gethash (cons m (1- n)) vmap) :left)
|
||||
(plist-get (gethash (cons m (1+ n)) vmap) :right)
|
||||
(plist-get (gethash (cons (1- m) n) vmap) :top)
|
||||
(plist-get (gethash (cons (1+ m) n) vmap) :bottom)))))
|
||||
(setq vmap (funcall vmap-update hprop (max h max-hor)))
|
||||
(setq vmap (funcall vmap-update vprop (max h max-vert)))
|
||||
(setq vmap (funcall vmap-update :visible (advent/8/tree-is-visible hmap m n max-heights)))))
|
||||
(defun advent/8/count-trees-from-edge ()
|
||||
'(let ((h (advent/8/height-at hmap m n))
|
||||
(vmap-update (apply-partially #'advent/8/update-vmap vmap m n))
|
||||
(max-vert (or (advent/8/max-height-at vmap (+ m (* -1 step)) n vprop) 0))
|
||||
(max-hor (or (advent/8/max-height-at vmap m (+ n (* -1 step)) hprop) 0))
|
||||
(max-heights (-non-nil (list
|
||||
(plist-get (gethash (cons m (1- n)) vmap) :left)
|
||||
(plist-get (gethash (cons m (1+ n)) vmap) :right)
|
||||
(plist-get (gethash (cons (1- m) n) vmap) :top)
|
||||
(plist-get (gethash (cons (1+ m) n) vmap) :bottom)))))
|
||||
(setq vmap (funcall vmap-update hprop (max h max-hor)))
|
||||
(setq vmap (funcall vmap-update vprop (max h max-vert)))
|
||||
(setq vmap (funcall vmap-update :visible (advent/8/tree-is-visible hmap m n max-heights)))))
|
||||
|
||||
(defun advent/8/get-visibility-map (hmap process-cell-form)
|
||||
"Transforms the height map HMAP into a visibility map. Each cell is evaluated through PROCESS-CELL-FORM."
|
||||
|
|
Loading…
Reference in a new issue