WIP day 4

This commit is contained in:
Evie Litherland-Smith 2024-12-16 07:54:23 +00:00
parent b02a740fe9
commit 6c112f7be6

54
day4/run.py Normal file
View file

@ -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