From 033a31a7c06456525184b4500067e6d87d20eb2d Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Fri, 11 Dec 2020 13:52:48 +0100 Subject: [PATCH] day11: remove another 2 dict-accesses --- day11.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/day11.py b/day11.py index 7b48fae..4998031 100644 --- a/day11.py +++ b/day11.py @@ -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)]