integers = [int(number) for number in input().split()]
K = int(input())
triplets =[]
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if a+b+c == K:
triplets.append(tuple((a,b,c))
sorted_triplets=[]
for tripl in triplets:
item = sorted(tripl)
sorted_triplets.append(item)
triplets= sorted(sorted_triplets) output:[0, 8, 21] output should be like this:(0, 8, 21)
[0, 12, 17] (0, 12, 17)
[8, 9, 12] (8, 9, 12)
if len(triplets)!=0:
for triplet in triplets:
triplet=sorted(triplet)
print(triplet)
else:
print("No Matching Triplets Found")
integers = [int(number) for number in input().split()]
K = int(input())
triplets =[]
for i in range(len(integers)):
for j in range(i+1,len(integers)):
for k in range(j+1, len(integers)):
a = integers[i]
b = integers[j]
c = integers[k]
if a+b+c == K:
triplets.append(tuple((a,b,c)))
sorted_triplets=[]
for tripl in triplets:
item = sorted(tripl)
sorted_triplets.append(item)
triplets= sorted(sorted_triplets)
if len(triplets)!=0:
for triplet in triplets:
triplet=sorted(triplet)
print(tuple((triplet)))
else:
print("No Matching Triplets Found")
Comments
Leave a comment