2025(04): solve part 2, change to function to what they should have been in 1

This commit is contained in:
2025-12-05 09:42:33 +01:00
parent fe54ab36aa
commit 22dec5e521
2 changed files with 30 additions and 2 deletions

View File

@ -36,14 +36,18 @@ def count_neighbours(tp_map):
dX, dY = X.copy() + x, Y.copy() + y
legal_idx = (dX >= 0)*(dX < L_x)*(dY >= 0)*(dY < L_y)*((dX != x)|(dY != y))
neighbour_counts[x, y] = (tp_map[dX[legal_idx], dY[legal_idx]]).sum()
return neighbour_counts
def count_extractable(tp_map):
neighbour_counts = count_neighbours(tp_map)
max_rolls = 4
return (neighbour_counts[tp_map] < max_rolls).sum()
if __name__ == "__main__":
test_map = read_map("testinput")
# print(test_map)
assert count_neighbours(test_map) == 13
assert count_extractable(test_map) == 13
# TODO: Compare the output map.
real_map = read_map("input")
print(count_neighbours(real_map))
print(count_extractable(real_map))