This commit is contained in:
Luke Hubmayer-Werner 2022-12-19 01:31:31 +10:30
parent ca78b6d7c6
commit f196b34fba
1 changed files with 6 additions and 6 deletions

View File

@ -29,12 +29,12 @@ def count_faces(coords: list[tuple[int,int,int]], count_gaps=True):
if not count_gaps: if not count_gaps:
field[flood(field, (0,0,0), connectivity=1)] = -1 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 return surface_area
print(f'Part 1 (sample): {count_faces(sample_coords)}') print(f'Part 1 (sample): {count_faces(sample_coords)}')