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))) input:0 12 17 8 9 21
sorted_triplets=[] 29
for tripl in triplets:
item = sorted(tripl) output:[0, 8, 21]
sorted_triplets.append(item) [0, 12, 17]
triplets= sorted(sorted_triplets) [8, 9, 12]
if len(triplets)!=0:
for triplet in triplets: output should be like this:(0, 8, 21)
triplet=sorted(triplet) (0, 12, 17)
print(triplet) (8, 9, 12)
else: output should be in round braces
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(triplet)
else:
print("No Matching Triplets Found")
Comments
Leave a comment