Add day4 part1 solution
This commit is contained in:
parent
16d8f293eb
commit
2491ef0518
140
day4/input.txt
Normal file
140
day4/input.txt
Normal file
|
@ -0,0 +1,140 @@
|
|||
ASAMXXXXSSMMSMAXSAXXXMAMXAMXMMAMXMMMMSSMMMMMMMMMSMXSASXSMXMMMXAMSSSMSSXMXMASMSMMMSMASXMMMAMXMXMMXSXMASMSMXMASMXSMXMAMXMMSMSASAMXSXMAMSAMXSSS
|
||||
SAMXSXXMAAAAXMXSAMXSMXMSSXXAMMAMAMXMAMASMAMAXMAMXAXSAXAXAASAMSAMAAAAAAASXMASMSAXAAXAMAMXMMXSSMMSAMXSXAAAAASAMXAMASXMASXAAAXASMSMSAAAXXAXXMAM
|
||||
MAMAAAMAXSMMMMXSAXMAMAMMAMSMMSXSASMMMSAMXAXMSSXSMMMMMMSMSMSAMSAMMXMMMMASAMAMXSAMSSMMSMSMSMAMXAXMASAMXMSMXMSMXMXMAMAMASMMMSMMMAAAMXMAMMSMAMAM
|
||||
SAMXSSXSMMMSAMASXMMASAMSAMAMXMAMMMXAMMASXSSMAMAAXXAAAMAAXXMMMSXMXSXAAXAMXMAMAMXMXAMXAAAAAMAMMSMMSAMXAMAMSMXMAMAMAXAMXMAAAXAAMMMMMXMAMSAMXSMS
|
||||
MXMAMAAAXAAMAMMMMXSAMMXSMSXSAAMSMSMMMXASAMXMAXSMMXSMSSMSSMXMASMXXAMMMMSSXSASMMMASXMMMSMSMSXSAMAXXAXMXXASAMAXAXAMMMSXXXMMSSSMXSASASMSMAAXMAXA
|
||||
XSAMXMSMMMSXXMASMMMSSMAMXXXSXSXAXAAAMMXMMMXMXXAAXMMAMXXAAMMMXSASXMAXXAXXASAXAAXMXMXSAMXAAXXMASMXSSMSSSXSAMXSSSMMSAMASMMAAAAAASMAAXAAMMMASXMS
|
||||
MSASXXXASAMMXMAAXAAMXMSSSMAXAMMMSXSMSAMMSSMMMASAAAMAMMMSSMASMMAMXXMSMSSMASMSSMSMMASMASXMSMSAMXMXA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AAMASXAMMSSMMMXSXMSXAX
|
||||
MSMMMMMXAMAMMSMMAMMSXMAMMMSMSAXMMMAMXXMAMXMAMSAMAXXXMAXSAXMAXSASXSMASMMSSMAAXAXMSXSMSAMXSSMXSAAXXMAMAXAXASAMXMXAXMXXXMXSSMSMXMMAAXAXXMASXSSS
|
76
day4/run.py
76
day4/run.py
|
@ -24,7 +24,7 @@ class FindXMAS:
|
|||
|
||||
@property
|
||||
def _part1(self) -> int:
|
||||
pass
|
||||
return len(self.locate_xmas())
|
||||
|
||||
@property
|
||||
def _part2(self) -> None:
|
||||
|
@ -34,56 +34,52 @@ class FindXMAS:
|
|||
def _to_grid(input: str) -> List[List[str]]:
|
||||
return [list(line) for line in input.splitlines() if line]
|
||||
|
||||
def _find_neighbours(
|
||||
def find_neighbours(
|
||||
self,
|
||||
origin: Tuple[int, int],
|
||||
bounds: Tuple[Tuple[int, int], ...] = ((-1, 1), (-1, 1)),
|
||||
locations: Tuple[Tuple[int, ...]] = (),
|
||||
target: str = "XMAS",
|
||||
) -> Tuple[int, ...]:
|
||||
if len(target) <= 1:
|
||||
return locations
|
||||
current = self.inputgrid[origin[0]][origin[1]]
|
||||
next = target[target.find(current) + 1]
|
||||
for row in range(origin[0] + bounds[0][0], origin[0] + bounds[0][1] + 1):
|
||||
for col in range(origin[1] - bounds[1][0], origin[1] + bounds[1][1] + 1):
|
||||
if any(
|
||||
(
|
||||
row < 0,
|
||||
row >= len(self.inputgrid[0]),
|
||||
col < 0,
|
||||
col >= len(self.inputgrid),
|
||||
)
|
||||
):
|
||||
) -> List[Tuple[Tuple[int, ...]]]:
|
||||
locations: List[Tuple[Tuple[int, ...]]] = []
|
||||
x, y = origin
|
||||
if self.inputgrid[x][y].upper() != target[0].upper():
|
||||
return []
|
||||
for dx in range(-1, 2):
|
||||
for dy in range(-1, 2):
|
||||
if dx == 0 and dy == 0:
|
||||
continue
|
||||
if self.inputgrid[row][col].upper() == next.upper():
|
||||
return self._find_neighbours(
|
||||
origin=(row, col),
|
||||
bounds=(
|
||||
(-1 if row < origin[0] else 0, 1 if row > origin[0] else 0),
|
||||
(-1 if col < origin[1] else 0, 1 if col > origin[1] else 0),
|
||||
),
|
||||
locations=(
|
||||
locations,
|
||||
(row, col),
|
||||
),
|
||||
target=target[1:],
|
||||
)
|
||||
current = [(x, y)]
|
||||
for n in range(1, len(target)):
|
||||
nx = x + (n * dx)
|
||||
ny = y + (n * dy)
|
||||
if nx < 0 or ny < 0:
|
||||
continue
|
||||
try:
|
||||
if self.inputgrid[nx][ny].upper() == target[n].upper():
|
||||
current.append((nx, ny))
|
||||
except IndexError:
|
||||
pass
|
||||
if len(current) == 4:
|
||||
locations.append(tuple(current))
|
||||
return locations
|
||||
|
||||
def locate_xmas(self) -> List[Tuple[int, int, int, int]]:
|
||||
location: List[Tuple[int, ...]] = []
|
||||
def locate_xmas(self) -> List[Tuple[Tuple[int, ...]]]:
|
||||
locations: List[Tuple[Tuple[int, ...]]] = []
|
||||
|
||||
for i, line in enumerate(self.inputgrid):
|
||||
for j, char in enumerate(line):
|
||||
if char.upper() == "X":
|
||||
location.append(self._find_neighbours((i, j), target="XMAS"))
|
||||
neighbours = self.find_neighbours((i, j), target="XMAS")
|
||||
if neighbours is None:
|
||||
continue
|
||||
locations = [*locations, *neighbours]
|
||||
|
||||
return location
|
||||
return locations
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
example = FindXMAS(EXAMPLE)
|
||||
print(example._find_neighbours((0, 4)))
|
||||
print(example.locate_xmas())
|
||||
# print(example)
|
||||
# assert example._part1 == 18
|
||||
print(example)
|
||||
assert example._part1 == 18
|
||||
with open("input.txt", "r") as f:
|
||||
puzzle = FindXMAS(f.read())
|
||||
print(puzzle)
|
||||
|
|
Loading…
Reference in a new issue