We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cf16150 commit 8590718Copy full SHA for 8590718
day23/python/Combinationsum.py
@@ -0,0 +1,18 @@
1
+Name:Dipto Chakrabarty
2
+Topic:Combination Sum
3
+Date:1/02/2019
4
+
5
+from itertools import combinations_with_replacement
6
+l=list(map(int,input().split())) #taking inputs and storing in list
7
+n=int(input()) #input of required sum
8
+k=len(l) #length of list
9
+d=[]
10
+for i in range(k):
11
+ t=list(combinations_with_replacement(l,i+1)) #total combinations of the list
12
+ d.append(t) #adding it to another list
13
14
+for i in range(len(d)):
15
+ for j in range(len(d[i])):
16
+ if(n==(sum(d[i][j]))): #checking if list element equals required number
17
+ print(list(d[i][j]))
18
0 commit comments