generated from public/aoc_template
day12
This commit is contained in:
parent
edc59f45ba
commit
fc55b91f7c
37
day12.py
Normal file
37
day12.py
Normal file
@ -0,0 +1,37 @@
|
||||
from tools.aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
from tools.grid import Grid
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
inputs = [
|
||||
[
|
||||
#(2, "input12_test"), # the test is a lie
|
||||
(544, "input12"),
|
||||
],
|
||||
[
|
||||
(None, "input12"),
|
||||
]
|
||||
]
|
||||
|
||||
def part1(self) -> Any:
|
||||
blocks = self.getMultiLineInputAsArray()
|
||||
presents = {int(p[0][0]): Grid.from_data(p[1:], translate={'#': True, '.': False}).getOnCount() for p in blocks[:-1]}
|
||||
ans = 0
|
||||
for tree in blocks[-1]:
|
||||
dim, pw = tree.split(": ")
|
||||
row, col = map(int, dim.split("x"))
|
||||
grid_size = row * col
|
||||
present_size = sum(x * presents[i] for i, x in enumerate(map(int, pw.split())))
|
||||
if present_size < grid_size:
|
||||
ans += 1
|
||||
return ans
|
||||
|
||||
def part2(self) -> Any:
|
||||
return ""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
day = Day(2025, 12)
|
||||
day.run(verbose=True)
|
||||
1030
inputs/input12
Normal file
1030
inputs/input12
Normal file
File diff suppressed because it is too large
Load Diff
33
inputs/input12_test
Normal file
33
inputs/input12_test
Normal file
@ -0,0 +1,33 @@
|
||||
0:
|
||||
###
|
||||
##.
|
||||
##.
|
||||
|
||||
1:
|
||||
###
|
||||
##.
|
||||
.##
|
||||
|
||||
2:
|
||||
.##
|
||||
###
|
||||
##.
|
||||
|
||||
3:
|
||||
##.
|
||||
###
|
||||
##.
|
||||
|
||||
4:
|
||||
###
|
||||
#..
|
||||
###
|
||||
|
||||
5:
|
||||
###
|
||||
.#.
|
||||
###
|
||||
|
||||
4x4: 0 0 0 0 2 0
|
||||
12x5: 1 0 1 0 2 2
|
||||
12x5: 1 0 1 0 3 2
|
||||
Loading…
Reference in New Issue
Block a user