Triplet Sum
Write a Python Program for Triplet Sum
The below link contains Triplet Sum Question and test cases
https://drive.google.com/file/d/1kPR1eOaf9JTOqqAj4w_A4e8Nc0jIa3fM/view?usp=sharing
integers = [int(number) for number in input().split()]
integers.sort()
K = int(input())
triplets = []
for i in range(len(integers)):
for j in range(len(integers)):
for k in range(len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if a+b+c == K:
triplet = [a,b,c]
triplet.sort()
triplet = tuple(triplet)
if triplet not in triplets:
triplets.append(triplet)
if len(triplets) == 0:
print("No Matching Triplets Found!")
else:
for triplet in triplets:
print(triplet)
Comments
Leave a comment