Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Itertools Usage solution in Clear category for Similar Triangles by DWild
import itertools
def similar_triangles(coords_1, coords_2):
sides = lambda crd: itertools.starmap(lambda a,b: (a[0]-b[0])**2 + (a[1]-b[1])**2, list(itertools.combinations(crd,2)))
s1 = list(sides(coords_1))
for s2 in itertools.permutations(sides(coords_2), 3):
res = list(itertools.starmap(lambda a,b: round(a/b,9), zip(s1,s2)))
if res[0]==res[1] and res[1]==res[2]:
return True
return False
Dec. 15, 2021