From 806f6dab6102c2dfb9a37a608f20b5bf68f42a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Rasmussen?= Date: Fri, 11 Dec 2020 08:15:48 +0100 Subject: [PATCH] Day 11 - Task 1 --- 2020/11/data.txt | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 2020/11/main.py | 89 ++++++++++++++++++++++++++++++++++++++++++ 2020/11/test-1.txt | 10 +++++ 2020/11/test.txt | 10 +++++ 4 files changed, 206 insertions(+) create mode 100644 2020/11/data.txt create mode 100644 2020/11/main.py create mode 100644 2020/11/test-1.txt create mode 100644 2020/11/test.txt diff --git a/2020/11/data.txt b/2020/11/data.txt new file mode 100644 index 0000000..bbaf4ea --- /dev/null +++ b/2020/11/data.txt @@ -0,0 +1,97 @@ +LLLLLLLLL.L.LLL.L.LLLLL.LLLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL.LLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL +LLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL +LLLLLLLLLLLLL.LLLLLLLLL.LLLLLLLLLLLLLLLLL.LLLLLL.LLLLLL.LLLLLLLLLLLL.LLLLLL.LLLLL.LLLLLLL.LLLLLLLL +LLLLLLLLLLLLLLL.LLLLLLL.LLL.LLLLLLLLLLLLLLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLL +L..LL.L.L....L..L.L....L.....L.L.L......L..L..L....L.LL.......L.....L....L..L................L.... +LLLLLLLLLLLLLLL.LLL.LLL.LLLLLLLLLLLLLLLLL.LLLLLLL.LLLLLLLLLLLLL.LLLLLLL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L.LLLLLLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLL.LLLLLL.LLLLL.LLLLLLLLLLLLLLLL +LLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLLL.LLLLLLL.LLLL..LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL.LLLLLLLL +LLLLLLLLL.LLLLL.LLLLLLLLLLLLLLLL.LLLLLLLL.LLLLLLL.LLL.L.LLLLLLLLLLLL.LLLLLLLLLLLLLLLLLLLL.LLLLLLLL diff --git a/2020/11/main.py b/2020/11/main.py new file mode 100644 index 0000000..21d9380 --- /dev/null +++ b/2020/11/main.py @@ -0,0 +1,89 @@ +import copy +from pprint import pprint + + +class PuzzleSolver: + def __init__(self, filename): + self.load(filename) + + def load(self, filename): + with open(filename, "r", encoding="utf-8") as f: + self.data = [list(x.rstrip()) for x in f.readlines()] + self.width = len(self.data[0]) + self.height = len(self.data) + + def is_adjacent(self, x1, y1, x2, y2): + dy = abs(y2 - y1) + dx = abs(x2 - x1) + return dy <= 1 and dx <= 1 + + def occupied_adjacent(self, x, y): + n = 0 + for j in range(y-1, y+2): + for i in range(x-1, x+2): + if (i, j) == (x, y): + continue + if not (0 <= i < self.width): + continue + if not (0 <= j < self.height): + continue + + s = self.get(i, j) + if s == "#": + n += 1 + + return n + + def get(self, x, y): + return self.data[y][x] + + def mutate(self): + ret = copy.deepcopy(self.data) + for y in range(self.height): + for x in range(self.width): + s = self.get(x, y) + if s == ".": + continue + + n = self.occupied_adjacent(x, y) + if s == "L": + if n == 0: + ret[y][x] = "#" + elif s == "#": + if n >= 4: + ret[y][x] = "L" + + return ret + + def print(self): + for y in range(self.height): + print("".join(self.data[y])) + print() + + def solve(self): + stable = False + rounds = 0 + self.print() + while not stable: + x = self.mutate() + stable = x == self.data + self.data = x + rounds += 1 + + self.print() + + return rounds + + def count_occupied(self): + return sum([x.count("#") for x in self.data]) + + +ps = PuzzleSolver("test.txt") +rounds = ps.solve() +cs = PuzzleSolver("test-1.txt") +assert ps.data == cs.data + +ps = PuzzleSolver("data.txt") +rounds = ps.solve() +n = ps.count_occupied() +print(f"There are {n} occupied seats.") diff --git a/2020/11/test-1.txt b/2020/11/test-1.txt new file mode 100644 index 0000000..dbd760e --- /dev/null +++ b/2020/11/test-1.txt @@ -0,0 +1,10 @@ +#.#L.L#.## +#LLL#LL.L# +L.#.L..#.. +#L##.##.L# +#.#L.LL.LL +#.#L#L#.## +..L.L..... +#L#L##L#L# +#.LLLLLL.L +#.#L#L#.## diff --git a/2020/11/test.txt b/2020/11/test.txt new file mode 100644 index 0000000..1beaede --- /dev/null +++ b/2020/11/test.txt @@ -0,0 +1,10 @@ +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