From d7fbb4d559ad5342123b290dcc8c2a02a359aff2 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Fri, 11 Dec 2020 17:46:04 +1030 Subject: [PATCH] Clean up ANDs --- 2020/day11.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/2020/day11.py b/2020/day11.py index c8cf2e1..0018882 100644 --- a/2020/day11.py +++ b/2020/day11.py @@ -10,8 +10,8 @@ def sim_step(seatmap, seatfilled): src = dir_slices[(i+4)%8] neighbours[dst] += seatfilled[src] output = seatfilled.copy() - output[np.logical_and(seatfilled==True, neighbours>=4)] = False - output[np.logical_and(seatfilled==False, np.logical_and(neighbours==0, seatmap==True))] = True + output[(seatfilled==True) & (neighbours>=4)] = False + output[(seatfilled==False) & (neighbours==0) & (seatmap==True)] = True return output occupied_seats = seatmap & False @@ -36,8 +36,8 @@ def sim_step_los(seatmap, seatfilled): break neighbours[dst] += fill2[src] output = seatfilled.copy() - output[np.logical_and(seatfilled==True, neighbours>=5)] = False - output[np.logical_and(seatfilled==False, np.logical_and(neighbours==0, seatmap==True))] = True + output[(seatfilled==True) & (neighbours>=5)] = False + output[(seatfilled==False) & (neighbours==0) & (seatmap==True)] = True return output occupied_seats = seatmap & False