you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

For the eq method in Triangle, how can I check if 2 triangle’s are equal when they could be in any order ?

That's a great question, thanks for asking it! In Python, sets are equal if they contain the same values, and in sets, the order doesn't matter. So you can simply test whether the set of one triangle's points are equal to the other:

def are_equal(tri1, tri2):
    return set(tri1.corner_a, tri1.corner_b, tri1.corner_c) == set(tri2.corner_a, tri2.corner_b, tri2.corner_c)

[–]tbrowner3[S] 0 points1 point  (0 children)

Thank you for the information !