blob: aeda572f052b7a94289491843bde9fd8902fd15e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/usr/bin/sbcl --script
(load "../interpreter.lisp")
(defun main (filename)
(let ((blocks (make-hash-table))
parts)
(intcode:run (intcode:parse "input") nil
(lambda (msg)
(if (< (length parts) 2)
(push msg parts)
(let ((y (first parts))
(x (second parts)))
(when (= msg 2)
(setf (gethash (complex x y) blocks) t))
(setq parts nil)))))
(hash-table-count blocks)))
(format t "~d~%" (main "input"))
|