day11: remove another 2 dict-accesses

This commit is contained in:
Stefan Harmuth 2020-12-11 13:52:48 +01:00
parent 6df1f468d3
commit 033a31a7c0

View File

@ -55,8 +55,10 @@ def simulate(layout, max_x, max_y, wide=False):
occupied_seats += layout[(test_x, test_y)]
break
if (layout[(x, y)] and occupied_seats >= max_seats_occupied) or (not layout[(x, y)] and occupied_seats == 0):
new_layout[(x, y)] = not layout[(x, y)]
if occupied_seats >= max_seats_occupied:
new_layout[(x, y)] = False
elif occupied_seats == 0:
new_layout[(x, y)] = True
else:
new_layout[(x, y)] = layout[(x, y)]