Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions day21/Python/PairSumN_Dipto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'''
Name:Dipto Chakrabarty
Date:17/01/2019
Day 21
Question:Pair Sum N
'''

def pairSumN(l,n):
t=[]
k=len(l)
l.sort()
print(l)
#sorting the list (incase list is unsorted)
for i in range(k-1):
#using nested list to loop through elements
for j in range(i+1,k):
s=l[i]+l[j]
if(s==n):
#checking if sum of elements is equal to required no
t=[l[i],l[j]]
return t
#return list with required elements
return t
#else returns empty list
l=list(map(int,input().split()))
#taking the array input
num=int(input())
#desired sum needed
a=pairSumN(l,num)
print(a)