diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-12 07:13:48 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-12 07:13:48 +0100 |
| commit | fad0e790ec93eb4c9f4b993041000338e2d59996 (patch) | |
| tree | 6584ed573248dea1a00049972c5c13436e9c6968 /2025/12/a.py | |
| parent | 23494faa0f69b4aa0bb0e83cdbcf8657e14266d5 (diff) | |
| download | aoc-fad0e790ec93eb4c9f4b993041000338e2d59996.tar.gz aoc-fad0e790ec93eb4c9f4b993041000338e2d59996.zip | |
Diffstat (limited to '2025/12/a.py')
| -rw-r--r-- | 2025/12/a.py | 21 |
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 | |||
| 1 | import fileinput | 4 | import fileinput |
| 2 | 5 | ||
| 6 | def present_area(lines5): | ||
| 7 | return sum(l.count('#') for l in lines5) | ||
| 8 | |||
| 9 | def 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 | |||
| 15 | def fits(wh, c, areas): | ||
| 16 | return wh[0]*wh[1] >= sum(c[i] * areas[i] for i in range(6)) | ||
| 17 | |||
| 3 | with fileinput.input() as lines: | 18 | with 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 | ||
| 23 | print(sum(1 if fits(*region, areas) else 0 for region in regions)) | ||
