From 6c112f7be67909b5af618db1af44b3ec518708f4 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 16 Dec 2024 07:54:23 +0000 Subject: [PATCH] WIP day 4 --- day4/run.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 day4/run.py diff --git a/day4/run.py b/day4/run.py new file mode 100644 index 0000000..1a5d35d --- /dev/null +++ b/day4/run.py @@ -0,0 +1,54 @@ +from typing import List, Tuple + +EXAMPLE = """ +MMMSXXMASM +MSAMXMSMSA +AMXSXMAAMM +MSAMASMSMX +XMASAMXAMM +XXAMMXXAMA +SMSMSASXSS +SAXAMASAAA +MAMMMXMMMM +MXMXAXMASX +""" + + +class FindXMAS: + def __init__(self, input: str) -> None: + self.input = input + self.inputgrid = self._to_grid(self.input) + + def __str__(self) -> str: + return f"Part1: {self._part1}\nPart2: {self._part2}" + + @property + def _part1(self) -> int: + pass + + @property + def _part2(self) -> None: + pass + + @staticmethod + def _to_grid(input: str) -> List[List[str]]: + return [list(line) for line in input.splitlines() if line] + + def locate_xmas(self) -> List[Tuple[int, int, int, int]]: + locate: Tuple[int, ...] = [] + for i, line in enumerate(self.inputgrid): + for j, char in enumerate(line): + if char.upper() == "X": + for k, contchar in enumerate(("M", "A", "S")): + offset = k + 1 + for row in range(i - offset, i + offset + 1): + for col in range(j - offset, j + offset + 1): + pass + + return locate + + +if __name__ == "__main__": + example = FindXMAS(EXAMPLE) + print(example) + assert example._part1 == 18