aboutsummaryrefslogtreecommitdiff
path: root/2025/12/a.py
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-12-12 07:13:48 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2025-12-12 07:13:48 +0100
commitfad0e790ec93eb4c9f4b993041000338e2d59996 (patch)
tree6584ed573248dea1a00049972c5c13436e9c6968 /2025/12/a.py
parent23494faa0f69b4aa0bb0e83cdbcf8657e14266d5 (diff)
downloadaoc-fad0e790ec93eb4c9f4b993041000338e2d59996.tar.gz
aoc-fad0e790ec93eb4c9f4b993041000338e2d59996.zip
Merry Christmas?HEADmaster
Diffstat (limited to '2025/12/a.py')
-rw-r--r--2025/12/a.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/2025/12/a.py b/2025/12/a.py
index 5fdb11b..cac2c38 100644
--- a/2025/12/a.py
+++ b/2025/12/a.py
@@ -1,6 +1,23 @@
1# Just estimate if the shape fit basd on the area. I feel like I am
2# being pranked, this problem sucks.
3
1import fileinput 4import fileinput
2 5
6def present_area(lines5):
7 return sum(l.count('#') for l in lines5)
8
9def region(line):
10 wh, n = line[:-1].split(': ')
11 wh = tuple(int(i) for i in wh.split('x'))
12 c = [int(i) for i in n.split(' ')]
13 return wh, c
14
15def fits(wh, c, areas):
16 return wh[0]*wh[1] >= sum(c[i] * areas[i] for i in range(6))
17
3with fileinput.input() as lines: 18with fileinput.input() as lines:
4 for line in lines: 19 lines = list(lines)
5 ... 20 areas = [present_area(lines[5*i:5*(i+1)]) for i in range(6)]
21 regions = [region(line) for line in lines[30:]]
6 22
23print(sum(1 if fits(*region, areas) else 0 for region in regions))

Generated with cgit - Back to sebastiano.tronto.net