Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Grow radius & winnow candidates solution in Clear category for Landing Site by juestr
def landing_site(obstacles):
grid = {(c, r) for c in range(12) for r in range(9)}
good = grid - {(ord(o[0])-65, ord(o[1])-49) for o in obstacles}
def winnow(candidates, radius):
def distance(a, b):
dx = b[0] - a[0]
dy = b[1] - a[1] - b[0] // 2 + a[0] // 2
return abs(dx + dy) if (dx > 0) == (dy > 0) else max(abs(dx), abs(dy))
def valid(center):
return radius * 6 == sum(1 for cell in good if distance(center, cell) == radius)
return [c for c in candidates if valid(c)]
radius = 1
best, candidates = set(), winnow(good, radius)
while candidates:
radius += 1
best, candidates = candidates, winnow(candidates, radius)
return {chr(c[0]+65) + chr(c[1]+49) for c in best}
Oct. 25, 2019
Comments: