From 955fe99709e9fd567d2a296e8eee7a1c459ea439 Mon Sep 17 00:00:00 2001 From: Jack Kinsey Date: Sun, 13 Dec 2020 04:58:43 -0500 Subject: [PATCH] Add day 11 --- res/day11 | 92 ++++++++++++++++++++++++++++ src/day11.lisp | 162 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+) create mode 100644 res/day11 create mode 100644 src/day11.lisp diff --git a/res/day11 b/res/day11 new file mode 100644 index 0000000..a6f636f --- /dev/null +++ b/res/day11 @@ -0,0 +1,92 @@ +LLLLL.LLL.LLLLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLL.LLLLLLL.LLLLLLL.LLLLL.LLLLLLLLLLLLLLLLLLL.LLLLL +LLLLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLL.LLLLLL.L.LLLL.LLL.L.LLLLL +LLLLLLLLL.LLLLLL.L.LLLLLL.LLLLLLLLL.LLLL...LLLLLL.LLLLLLL.LLLLLLL.LLLLLLLLLLLLLLLLLLL.LLLLL.LLLLL +LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLL.L.LLLLLL.LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLL..LLLLLL.LLLLLLLLLLLLLLLLL..LLLLLL.LLLLLLL.LLLLLLL.LLLLL.LLLLLLLL.LLLL.LLLLLLLLLLL +LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLL.LLLLLLL.LL.LLLL.LLLLLLL.LLLLL.LLLLLLLLLLLLL.LLLLLLLLLLL +LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLLLL..LLLLLLLLLLLLL.LLLL.LLLLLLLLLLL +LLLLLLLLL.LLLLLLL.L.LLLLL.LLLLLLLLL.LLLLL.LLLLLLL.LLLLLLLLLLLLLL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LLLLLLLLLLLLLLL.LLLLL +....L...L.....L..L...LL.L....L......L.....L..LL...L.......L....L.....L.L..L...L..........LL.LL... +LLLLL.LLL.LLLLLL.LLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL..LLLLL.LLLLLLLL.LLLLLLLLLLLLLLLL +LLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL.LLLL.LL.LLLLLLL..LLLLLLLLLLLLL.LLLLL.LLLL.LLLLL +LLLLLLLLL.L.LLLLLLLLLLLLL.LLLLLLLLL.L..LLLLLLLLLL.LLLLLLLLLLLLL.L.LLLLLLLLLLLLLL.LLLL.LLLLL.LLLLL +LLLL.LL.L.LLLLLL.LLLLLLLL.LLLL.LLLL..LLLL.LLLLLLL..LLLLLLLLLLLLLL.LLLLLLLLLLLLLL.LLLL.LLLLLLLLLLL +LLLLLL.LLLLLLLLLLLLLL.LLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLL.LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL +L.LLLLLLLLLLLLLL.LLLLL.LL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLL.LL.LLLLLLLLLLLLLLLLLLL.LLLLL.LLLLL +LLLLLLLL..LLLLLL.LLLLLLLLLLLLLLLL.L.LLLLL.LLLLLLLLLLLLLLL.LLLLLLL..LLLLLLLLLLLLL.LLLL.LLLLL.LLLLL +L...LLL.L..LL..L.LLL.....L......L...LLL..L....LLL..L...L...........L..L..L...LL.LL.L...LL.LLLLLL. +.LLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLL.LLLLL.LLLLL +LLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLL....LLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLL.LLL.LLLL.LLLLLLLLLLL +LLLLLLLLLLLLLLLLLLL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L.LL.LLLLL..LLLLL.LLLLLLL.L.LLLLL.LLLLLLL.LLLLL.LL.LLLLL.LLLLLLLLLL..LLLL +LLLLLLLLL.LLLLLL.LLLLLLLL.LLLLLL.LL.LLLLL.LLLLLLLLLLLLLLL.LLLLLLL...LLL.LLLLLLLL.LLLL.LLLLLLLLLLL +LLLLLLLLL.LLLLL.LLLLLLLLL.LLLLLLLLL.LLLLL.L.LLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLL.L.LLLL.LLLLL.LLLLL +LLLL.LLLL.LLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.L.LLLLLLLLLLLLLLLLLLLL.LLLL..LLLL.LLLLL +LLLLLLLLL.LLLLLL.LLLLLLLL.LLL.LLLLL.LLLLLLLLLLLLL.LLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLLLLL.LL.LL +LLLLLLLLL.LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLL.LLLL.LLLLLLL.LLLLLLL.LLLLL.LLLLLLLL.LLLL.LLLLLL.LLLL +LLLLLLLLLLLLLLLL.LLLLLLL..LLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLL.LLLL.L..LLLL.L.LLLLL..LLLL.LLLLL.LLLLL diff --git a/src/day11.lisp b/src/day11.lisp new file mode 100644 index 0000000..f5641dc --- /dev/null +++ b/src/day11.lisp @@ -0,0 +1,162 @@ +(asdf:load-system :adventofcode2020) +(in-package #:adventofcode2020) +(named-readtables:in-readtable fn-reader) + +(defun parse-layout (layout) + (make-array (list (length layout) (length (car layout))) + :initial-contents layout)) + +(defun get-surr (game) + (lambda (i j) + (if (char= #\. (aref game i j)) -1 + (->> + (map-product λ(list (funcall _0 i) (funcall _1 j)) + (list #'identity #'1+ #'1-) + (list #'identity #'1+ #'1-)) + (remove-if-not λ(apply #'array-in-bounds-p game _)) + (mapcar λ(apply #'aref game _)) + (count #\#))))) + +(defun get-sightlines (game) + (let ((functions (map-product #'list + (list #'identity #'1+ #'1-) + (list #'identity #'1+ #'1-)))) + (lambda (i j) + (if (char= #\. (aref game i j)) -1 + (loop for (f g) in functions + counting + (do ((fi (funcall f i) (funcall f fi)) + (gj (funcall g j) (funcall g gj))) + ((or (not (array-in-bounds-p game fi gj)) + (not (char= #\. (aref game fi gj))) + (and (= i fi) (= j gj))) + (when (array-in-bounds-p game fi gj) + (char= #\# (aref game fi gj)))))))))) + +(defun step-game (game &key (surr #'get-surr)) + (destructuring-bind (row col) (array-dimensions game) + (let* ((get-surr (funcall surr game)) + (seat-limit (if (eq surr #'get-surr) 5 6)) + (calc-next (lambda (i j) + (let ((occ (funcall get-surr i j)) + (val (aref game i j))) + (cond ((= occ 0) #\#) + ((>= occ seat-limit) #\L) + (t val)))))) + (->> + (loop for i below row collecting + (loop for j below col collecting (list i j))) + (mapcar λ(mapcar (curry #'apply calc-next) _)) + (parse-layout))))) + +(defun fixed-point (game &key (surr #'get-surr)) + (let ((step (step-game game :surr surr))) + (if (equalp game step) game + (fixed-point step :surr surr)))) + +(defun count-occupied (game) + (loop for i below (array-dimension game 0) + summing (loop for j below (array-dimension game 1) + counting (char= #\# (aref game i j))))) + +(day 11 input + (let ((game (parse-layout (list-from input)))) + (part1 (count-occupied (fixed-point game :surr #'get-surr))) + (part2 (count-occupied (fixed-point game :surr #'get-sightlines))))) + +(def-suite day11) +(in-suite day11) + +(defvar *simple-layout* + '("L.LL.LL.LL" + "LLLLLLL.LL" + "L.L.L..L.." + "LLLL.LL.LL" + "L.LL.LL.LL" + "L.LLLLL.LL" + "..L.L....." + "LLLLLLLLLL" + "L.LLLLLL.L" + "L.LLLLL.LL")) + +(test get-sightlines + (is (equal 8 (funcall (get-sightlines + (parse-layout '(".......#." + "...#....." + ".#......." + "........." + "..#L....#" + "....#...." + "........." + "#........" + "...#....."))) 4 3))) + (is (equal 0 (funcall (get-sightlines + (parse-layout '("............." + ".L.L.#.#.#.#." + "............."))) 1 1))) + (is (equal 0 (funcall (get-sightlines + (parse-layout '(".##.##." + "#.#.#.#" + "##...##" + "...L..." + "##...##" + "#.#.#.#" + ".##.##."))) 3 3)))) + +(test step-game + (is (equalp + (parse-layout '("#.LL.L#.##" + "#LLLLLL.L#" + "L.L.L..L.." + "#LLL.LL.L#" + "#.LL.LL.LL" + "#.LLLL#.##" + "..L.L....." + "#LLLLLLLL#" + "#.LLLLLL.L" + "#.#LLLL.##")) + (step-game (step-game (parse-layout *simple-layout*))))) + (is (equalp + (parse-layout '("#.LL.LL.L#" + "#LLLLLL.LL" + "L.L.L..L.." + "LLLL.LL.LL" + "L.LL.LL.LL" + "L.LLLLL.LL" + "..L.L....." + "LLLLLLLLL#" + "#.LLLLLL.L" + "#.LLLLL.L#")) + (step-game (step-game (parse-layout *simple-layout*) + :surr #'get-sightlines) + :surr #'get-sightlines)))) + +(test fix + (is (equalp + (parse-layout '("#.#L.L#.##" + "#LLL#LL.L#" + "L.#.L..#.." + "#L##.##.L#" + "#.#L.LL.LL" + "#.#L#L#.##" + "..L.L....." + "#L#L##L#L#" + "#.LLLLLL.L" + "#.#L#L#.##")) + (fixed-point (parse-layout *simple-layout*)))) + (is (equalp + (parse-layout '("#.L#.L#.L#" + "#LLLLLL.LL" + "L.L.L..#.." + "##L#.#L.L#" + "L.L#.LL.L#" + "#.LLLL#.LL" + "..#.L....." + "LLL###LLL#" + "#.LLLLL#.L" + "#.L#LL#.L#")) + (fixed-point (parse-layout *simple-layout*) + :surr #'get-sightlines)))) + + +(run! 'day11) -- 2.38.5