Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
complex set intersections solution in Clear category for Ore In The Desert by ogoro
from itertools import product, starmap
BOARD_SIZE = 10
ALL_CELLS = set(starmap(complex, product(range(BOARD_SIZE), repeat=2)))
def checkio(previous):
possible_cells = ALL_CELLS.copy()
for center_y, center_x, radius in previous:
center = complex(center_y, center_x)
possible_cells &= {cell for cell in possible_cells
if radius + 0.5 >= abs(cell - center) >= radius - 0.5}
next_cell = possible_cells.pop()
next_cell_coordinates = int(next_cell.real), int(next_cell.imag)
return next_cell_coordinates
April 9, 2021