def func(arr:list, n:int):
st = set()
for i in range(len(arr)):
for j in range(i, len(arr)):
for k in range(j, len(arr)):
if i != j and j != k and k != i:
if arr[i] + arr[j] + arr[k] == n:
st.add((arr[i], arr[j], arr[k]))
if (len(st) == 0):
print('No Matching Triplets Found')
else:
for item in sorted(st):
print(item)
if __name__=='__main__':
# read an array
arr = list(map(int, input().split()))
arr.sort()
# read a value
n = int(input())
func(arr, n)
Comments
Leave a comment