From 35e57f6e59423272fd4a45b2535c369cb61182b5 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 18 Dec 2024 20:37:45 +0100 Subject: Add 2019 day 13 solutions --- 2019/13/puzzle-1.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 2019/13/puzzle-1.lisp (limited to '2019/13/puzzle-1.lisp') diff --git a/2019/13/puzzle-1.lisp b/2019/13/puzzle-1.lisp new file mode 100755 index 0000000..aeda572 --- /dev/null +++ b/2019/13/puzzle-1.lisp @@ -0,0 +1,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")) \ No newline at end of file -- cgit v1.2.3