# Python3 program for the above approach
# Structure to represent a Triangle
# with three sides as a, b, c
class Triangle:
def __init__(self, a, b, c):
self.a = a
self.b = b
self.c = c
# Function to overload relational
# operator
def __eq__(self, t):
cnt = 0
if self.a in [t.a, t.b, t.c]:
cnt += 1
if self.b in [t.a, t.b, t.c]:
cnt += 1
if self.c in [t.a, t.b, t.c]:
cnt += 1
# If all the three elements a, b, c
# are same, triangle is not unique
if cnt == 3:
return False
# For unique triangle, return True
return True
# Function returns the number
# of unique Triangles
def countUniqueTriangles(arr, n):
# Unique sets
uni = 0;
for i in range(n - 1):
# Check on uniqueness for a
# particular set w.r.t others
cnt = 0;
for j in range(i, n - 1):
# Checks if two triangles
# are different
if (arr[i] == arr[j + 1]):
cnt += 1
# If count of unique triangles
# is same as the number of remaining
# triangles then, increment count
if (cnt == n - 1 - i):
uni+=1;
# Since last element that
# remains will be unique only
return uni + 1;
# Driver Code
# An array of structure to
# store sides of Triangles
arr = [ Triangle(3, 2, 2), Triangle(3, 4, 5), Triangle(1, 2, 2), Triangle(2, 2, 3), Triangle(5, 4, 3), Triangle(6, 4, 5) ]
n = len(arr)
# Function Call
print(countUniqueTriangles(arr, n))
# This code is contributed by phasing17.