···11+import fileinput
22+from collections import Counter
33+44+55+BLOCK_SIZES = Counter()
66+77+part_1 = 0
88+curr_block = None
99+1010+for line in fileinput.input():
1111+ line = line.strip()
1212+1313+ # Reading a region.
1414+ if 'x' in line:
1515+ size, counts = line.split(': ')
1616+ w, h = [int(x) for x in size.split('x')]
1717+ counts = [int(x) for x in counts.split()]
1818+1919+ region_area = w * h
2020+ block_area = sum(BLOCK_SIZES[i] * n for i, n in enumerate(counts))
2121+2222+ # The puzzle input is constructed to nicely tessellate the rectangular
2323+ # grid, so all we need to do is check if the area amount would work.
2424+ if block_area <= region_area:
2525+ ans += part_1
2626+2727+ else:
2828+ if ':' in line:
2929+ curr_block = int(line[:-1])
3030+ elif '#' in line or '.' in line:
3131+ BLOCK_SIZES[curr_block] += line.count('#')
3232+3333+print("Part 1:", part_1)
3434+