We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1334fc7 commit cb7b98bCopy full SHA for cb7b98b
1 file changed
lisp/src/day12.lisp
@@ -0,0 +1,23 @@
1
+(in-package #:aoc)
2
+
3
4
+(defun parse-sizes (filename)
5
+ (with-open-file (input-stream (aoc:input-path filename))
6
+ (loop with acc = '()
7
+ for line = (read-line input-stream nil nil)
8
+ while line
9
+ if (string= "" line)
10
+ do (setf acc '())
11
+ else
12
+ do (push (aoc:integers line) acc)
13
+ finally (return acc))))
14
15
+(defun fitsp (line)
16
+ (destructuring-bind (w h &rest amounts) line
17
+ (<= (* 9 (reduce #'+ amounts))
18
+ (* w h))))
19
20
+(defun day12 (&optional (filename 12))
21
+ (let ((lines (parse-sizes filename)))
22
+ (loop for line in lines
23
+ count (fitsp line))))
0 commit comments