Finished day 4
This commit is contained in:
parent
0cc04808b3
commit
86680b4174
|
@ -28,7 +28,7 @@ class FindXMAS:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _part2(self) -> int:
|
def _part2(self) -> int:
|
||||||
return len(self.locate_x_mas())
|
return len(self.locate_x_mas()) // 2
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _to_grid(input: str) -> List[List[str]]:
|
def _to_grid(input: str) -> List[List[str]]:
|
||||||
|
@ -98,13 +98,14 @@ class FindXMAS:
|
||||||
if loc[1] in oth:
|
if loc[1] in oth:
|
||||||
locations.append(loc)
|
locations.append(loc)
|
||||||
|
|
||||||
return mas
|
return locations
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
example = FindXMAS(EXAMPLE)
|
example = FindXMAS(EXAMPLE)
|
||||||
print(example)
|
print(example)
|
||||||
assert example._part1 == 18
|
assert example._part1 == 18
|
||||||
|
assert example._part2 == 9
|
||||||
with open("input.txt", "r") as f:
|
with open("input.txt", "r") as f:
|
||||||
puzzle = FindXMAS(f.read())
|
puzzle = FindXMAS(f.read())
|
||||||
print(puzzle)
|
print(puzzle)
|
||||||
|
|
Loading…
Reference in a new issue