Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Similar Triangles by tokiojapan55
from typing import List, Tuple
Coords = List[Tuple[int, int]]
from itertools import combinations
from math import sqrt
def similar_triangles(coords_1: Coords, coords_2: Coords) -> bool:
lines_1 = sorted([sqrt((s[0]-e[0])**2 + (s[1]-e[1])**2) for s,e in combinations(coords_1, 2)])
lines_2 = sorted([sqrt((s[0]-e[0])**2 + (s[1]-e[1])**2) for s,e in combinations(coords_2, 2)])
return len(set([line_1/line_2 for line_1,line_2 in zip(lines_1, lines_2)])) == 1
June 23, 2020
Comments: