generated from public/aoc_template
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from tools.aoc import AOCDay
|
|
from typing import Any
|
|
|
|
|
|
class Day(AOCDay):
|
|
inputs = [
|
|
[
|
|
(3, "input25_test"),
|
|
(3114, "input25"),
|
|
],
|
|
[
|
|
(None, "input25"),
|
|
],
|
|
]
|
|
|
|
def parse_input(self) -> tuple[list[list[int]], list[list[int]]]:
|
|
keys, locks = [], []
|
|
for key_lock in self.getMultiLineInputAsArray():
|
|
lens = []
|
|
for x in range(len(key_lock[0])):
|
|
lens.append(len([key_lock[y][x] for y in range(len(key_lock)) if key_lock[y][x] == "#"]) - 1)
|
|
if key_lock[0] == "#####":
|
|
locks.append(lens)
|
|
else:
|
|
keys.append(lens)
|
|
|
|
return keys, locks
|
|
|
|
def part1(self) -> Any:
|
|
ans = 0
|
|
keys, locks = self.parse_input()
|
|
for lock in locks:
|
|
for key in keys:
|
|
fits = True
|
|
for i, k in enumerate(key):
|
|
if k + lock[i] > 5:
|
|
fits = False
|
|
break
|
|
if fits:
|
|
ans += 1
|
|
|
|
return ans
|
|
|
|
def part2(self) -> Any:
|
|
return ""
|
|
|
|
|
|
if __name__ == "__main__":
|
|
day = Day(2024, 25)
|
|
day.run(verbose=True)
|