From f196b34fba81c0d1f9accaa92b886f31ff860df0 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Mon, 19 Dec 2022 01:31:31 +1030 Subject: [PATCH] align 1s --- 2022/day18.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/2022/day18.py b/2022/day18.py index 50a4606..6e43738 100644 --- a/2022/day18.py +++ b/2022/day18.py @@ -29,12 +29,12 @@ def count_faces(coords: list[tuple[int,int,int]], count_gaps=True): if not count_gaps: field[flood(field, (0,0,0), connectivity=1)] = -1 - surface_area = np.logical_and(field[:-1,:,:] == 1, field[1:,:,:] == -1).sum() - surface_area += np.logical_and(field[1:,:,:] == 1, field[:-1,:,:] == -1).sum() - surface_area += np.logical_and(field[:,:-1,:] == 1, field[:,1:,:] == -1).sum() - surface_area += np.logical_and(field[:,1:,:] == 1, field[:,:-1,:] == -1).sum() - surface_area += np.logical_and(field[:,:,:-1] == 1, field[:,:,1:] == -1).sum() - surface_area += np.logical_and(field[:,:,1:] == 1, field[:,:,:-1] == -1).sum() + surface_area = np.logical_and(field[:-1,:,:] == 1, field[ 1:,:,:] == -1).sum() + surface_area += np.logical_and(field[ 1:,:,:] == 1, field[:-1,:,:] == -1).sum() + surface_area += np.logical_and(field[:,:-1,:] == 1, field[:, 1:,:] == -1).sum() + surface_area += np.logical_and(field[:, 1:,:] == 1, field[:,:-1,:] == -1).sum() + surface_area += np.logical_and(field[:,:,:-1] == 1, field[:,:, 1:] == -1).sum() + surface_area += np.logical_and(field[:,:, 1:] == 1, field[:,:,:-1] == -1).sum() return surface_area print(f'Part 1 (sample): {count_faces(sample_coords)}')