Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6-liner: compare edges (no import) solution in Clear category for Similar Triangles by przemyslaw.daniel
def edges(coords):
pairs = zip(coords, coords[1:]+coords[:1])
return sorted((x1-x2)**2 + (y1-y2)**2 for (x1, y1), (x2, y2) in pairs)
def similar_triangles(coords1, coords2):
return len({x/y for x, y in zip(edges(coords1), edges(coords2))}) == 1
Jan. 26, 2020
Comments: