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-2.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2019/08/puzzle-2.el (limited to '2019/08/puzzle-2.el') diff --git a/2019/08/puzzle-2.el b/2019/08/puzzle-2.el new file mode 100644 index 0000000..61eed93 --- /dev/null +++ b/2019/08/puzzle-2.el @@ -0,0 +1,27 @@ +;;; -*- lexical-binding: t; -*- + +(defun main (filename) + (let* ((string (with-temp-buffer + (insert-file-contents-literally filename) + (buffer-substring-no-properties (point-min) (point-max)))) + (width 25) + (height 6) + (area (* width height)) + (image (thread-last + (seq-partition string area) + (apply #'seq-mapn #'first-visible-pixel) + (apply #'string)))) + (switch-to-buffer "*Advent of Code — 2019 Day 8*") + (save-excursion + (insert image)) + (while (not (eobp)) + (goto-char (+ (point) width)) + (insert ?\n)))) + +(defun first-visible-pixel (&rest pixels) + (pcase (seq-find (lambda (x) (/= x ?2)) pixels ?2) + (?0 ?.) + (?1 ?#) + (?2 32))) + +(main "input") \ No newline at end of file -- cgit v1.2.3