Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Count Chains by Oleg_Domokeev
from typing import List, Tuple
def count_chains(circles: List[Tuple[int, int, int]]) -> int:
def is_intersect(first, second):
triangle = [first[2], second[2], ((first[0]-second[0])**2 + (first[1]-second[1])**2)**0.5]
return 2*max(triangle) < sum(triangle)
count = 0
while circles:
step = {circles.pop()}
count += 1
while step:
one = step.pop()
for two in circles[:]:
if is_intersect(one, two):
circles.remove(two)
step.add(two)
return count
March 11, 2020
Comments: