generated from public/aoc_template
day25
This commit is contained in:
parent
be198cbc93
commit
fcecc00f49
50
day25.py
Normal file
50
day25.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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)
|
||||||
3999
inputs/input25
Normal file
3999
inputs/input25
Normal file
File diff suppressed because it is too large
Load Diff
39
inputs/input25_test
Normal file
39
inputs/input25_test
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#####
|
||||||
|
.####
|
||||||
|
.####
|
||||||
|
.####
|
||||||
|
.#.#.
|
||||||
|
.#...
|
||||||
|
.....
|
||||||
|
|
||||||
|
#####
|
||||||
|
##.##
|
||||||
|
.#.##
|
||||||
|
...##
|
||||||
|
...#.
|
||||||
|
...#.
|
||||||
|
.....
|
||||||
|
|
||||||
|
.....
|
||||||
|
#....
|
||||||
|
#....
|
||||||
|
#...#
|
||||||
|
#.#.#
|
||||||
|
#.###
|
||||||
|
#####
|
||||||
|
|
||||||
|
.....
|
||||||
|
.....
|
||||||
|
#.#..
|
||||||
|
###..
|
||||||
|
###.#
|
||||||
|
###.#
|
||||||
|
#####
|
||||||
|
|
||||||
|
.....
|
||||||
|
.....
|
||||||
|
.....
|
||||||
|
#....
|
||||||
|
#.#..
|
||||||
|
#.#.#
|
||||||
|
#####
|
||||||
Loading…
Reference in New Issue
Block a user