aboutsummaryrefslogtreecommitdiffstats
path: root/AoC2022/08/solver.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'AoC2022/08/solver.lisp')
-rw-r--r--AoC2022/08/solver.lisp12
1 files changed, 6 insertions, 6 deletions
diff --git a/AoC2022/08/solver.lisp b/AoC2022/08/solver.lisp
index 3797589..f5a273f 100644
--- a/AoC2022/08/solver.lisp
+++ b/AoC2022/08/solver.lisp
@@ -18,26 +18,26 @@
(defun solver-p1 (filename)
"Count how many trees are visible from the outside.
A tree is visible if all other trees between it and the edge of the grid are shorter."
- (multiple-value-bind (width height forest-arr) (forest (uiop:read-file-lines filename))
- (loop for base across forest-arr
+ (multiple-value-bind (width height forest) (forest (uiop:read-file-lines filename))
+ (loop for base across forest
and p from 0
count (some (lambda (direction)
(loop for l in (line-of-sight direction p width height)
- for tree-height = (aref forest-arr l)
+ for tree-height = (aref forest l)
always (< tree-height base)))
'(right left top bottom)))))
(defun solver-p2 (filename)
"A scenic score is the product of the viewing distance in each direction.
The viewing distance is the lenght until a tree of equal height appears."
- (multiple-value-bind (width height forest-arr) (forest (uiop:read-file-lines filename))
- (loop for base across forest-arr
+ (multiple-value-bind (width height forest) (forest (uiop:read-file-lines filename))
+ (loop for base across forest
and p from 0
maximize (apply #'*
(mapcar
(lambda (direction)
(loop for l in (line-of-sight direction p width height)
- for tree-height = (aref forest-arr l)
+ for tree-height = (aref forest l)
count l until (>= tree-height base)))
'(right left top bottom))))))