(mask: np.ndarray, seeds: np.ndarray)
| 427 | |
| 428 | |
| 429 | def flood_keep(mask: np.ndarray, seeds: np.ndarray) -> np.ndarray: |
| 430 | rows, cols = mask.shape |
| 431 | out = np.zeros_like(mask, dtype=bool) |
| 432 | q = deque() |
| 433 | ys, xs = np.where(seeds & mask) |
| 434 | for r, c in zip(ys.tolist(), xs.tolist()): |
| 435 | out[r, c] = True |
| 436 | q.append((r, c)) |
| 437 | while q: |
| 438 | r, c = q.popleft() |
| 439 | for rr, cc in hex_neighbors(r, c, rows, cols): |
| 440 | if mask[rr, cc] and not out[rr, cc]: |
| 441 | out[rr, cc] = True |
| 442 | q.append((rr, cc)) |
| 443 | return out |
| 444 | |
| 445 | |
| 446 | def water_break(cfg: Config) -> np.ndarray: |
no test coverage detected