blob: 05c0102bfac2df7d91482c67bdcac8b4e3b6d85d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
(ql:quickload '(fiveam uiop))
(defun distance-1 (a b)
(apply #'+
(mapcar (lambda (e1 e2)
(abs (- e1 e2))) a b)))
(defun surface (cubes)
(loop for a in cubes
sum (- 6 (loop for b in cubes
count (= 1 (distance-1 a b))))))
(defun parse-coords (filename)
(mapcar (lambda (l)
(mapcar #'parse-integer (uiop:split-string l :separator ",")))
(uiop:read-file-lines filename)))
(fiveam:test solutions
(fiveam:is (= 64 (surface (parse-coords "eg-in"))))
(fiveam:is (= 4474 (surface (parse-coords "input")))))
|