Skip to content

Commit 1fc3c6c

Browse files
authored
Create combinations - dealing with duplicates in combinations
1 parent fdb7033 commit 1fc3c6c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from itertools import combinations
2+
import numpy as np
3+
def dcomb(l, r):
4+
5+
# returns a list of all subsets of ur list 'l', of length r
6+
7+
return set(list(combinations(l, r)))
8+
print(combinations(l, r))
9+
10+
l = [1,2,2,4] #2 is duplicated
11+
r = 2
12+
dcomb(l, r)
13+
14+
15+
#print("total number of combinations =",len(dcomb(l, r)))
16+
17+

0 commit comments

Comments
 (0)