Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Similar Triangles by zwerkoff
from typing import List, Tuple
Coords = List[Tuple[int, int]]
def square_lengths(a, b, c):
l1 = (b[0] - a[0])**2 + (b[1] - a[1])**2
l2 = (c[0] - b[0])**2 + (c[1] - b[1])**2
l3 = (a[0] - c[0])**2 + (a[1] - c[1])**2
return sorted([l1, l2, l3])
def similar_triangles(coords_1: Coords, coords_2: Coords) -> bool:
sides1 = square_lengths(coords_1[0], coords_1[1], coords_1[2])
sides2 = square_lengths(coords_2[0], coords_2[1], coords_2[2])
return sides1[0]/sides2[0] == sides1[1]/sides2[1] and sides1[0]/sides2[0] == sides1[2]/sides2[2]
July 28, 2020
Comments: