From 069db00a05cdc880a44891e0cbb16543bfd57ebd Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 20 Dec 2024 09:02:44 +0100 Subject: Add 2019 day 8 solutions --- 2019/08/puzzle-1.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 2019/08/puzzle-1.el (limited to '2019/08/puzzle-1.el') diff --git a/2019/08/puzzle-1.el b/2019/08/puzzle-1.el new file mode 100644 index 0000000..ad82334 --- /dev/null +++ b/2019/08/puzzle-1.el @@ -0,0 +1,25 @@ +;;; -*- lexical-binding: t; -*- + +(defun main (filename) + (with-temp-buffer + (insert-file-contents-literally filename) + (let* ((width 25) + (height 6) + (area (* width height)) + (min-zeros most-positive-fixnum) + answer) + (while (not (eobp)) + (let* ((end (+ (point) area)) + (string (buffer-substring (point) end)) + (zeros (seq-count (make-= ?0) string))) + (when (< zeros min-zeros) + (setq min-zeros zeros + answer (* (seq-count (make-= ?1) string) + (seq-count (make-= ?2) string)))) + (goto-char end))) + answer))) + +(defun make-= (x) + (lambda (y) (= x y))) + +(message "%d" (main "input")) \ No newline at end of file -- cgit v1.2.3