1 (asdf:load-system :adventofcode2020)
2 (in-package #:adventofcode2020)
3 (named-readtables:in-readtable :adventofcode2020)
5 (defun tree-collisions (slope tree-map)
6 (loop with (rise run) = slope
7 with proper-map = (loop for j upfrom 0
9 when (->> rise (mod j) (= 0))
11 with terrain-width = (-> tree-map first length)
13 for terrain-line in proper-map
14 counting (->> terrain-width
20 (let ((tree-map (list-from input)))
21 (part1 (tree-collisions '(1 3) tree-map))
22 (part2 (->> '((1 1) (1 3) (1 5) (1 7) (2 1))
23 (mapcar λ(tree-collisions _ tree-map))
29 (test single-collision-check
32 (tree-collisions '(1 3) '("..##......."
45 (test multiple-collision-check
48 (mapcar λ(tree-collisions _ '("..##......."
59 '((1 1) (1 3) (1 5) (1 7) (2 1))))))