Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Count Chains by PythonWithPI
from typing import List, Tuple
def count_chains(circles: List[Tuple[int, int, int]]) -> int:
groups = []
while circles:
for group in groups:
for c in group:
for i, circle in enumerate(circles):
center_distance = (circle[0] - c[0]) ** 2 + (circle[1] - c[1]) ** 2
if center_distance <= (c[2] - circle[2]) ** 2:
continue
if center_distance < (c[2] + circle[2]) ** 2:
break
else:
continue
group.append(circle)
del circles[i]
break
else:
continue
break
else:
groups.append([circles.pop()])
return len(groups)
March 5, 2020