55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
|
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
|