-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_set.py
More file actions
31 lines (28 loc) · 773 Bytes
/
multi_set.py
File metadata and controls
31 lines (28 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def find_sub_set(n,k,offset):
result = []
if(k==1):
return [str(i) for i in range(offset,n)]
else:
for i in range(offset,n):
recur = find_sub_set(n,k-1,i)
for j in range(len(recur)):
r = recur[j]
result.append(str(i)+r)
return result
import math
def pred(n,k_i):
res = 1
for i in range(k_i):
res *= (n+k_i-1-i)/(k_i-i)
return res
if __name__=="__main__":
n = 3
k_i = 3
subsets = find_sub_set(n,k_i,0)
print(subsets)
exit()
for n in range(1,10):
for k_i in range(1,10):
subsets = find_sub_set(n,k_i,0)
print(len(subsets), pred(n,k_i),int(len(subsets)-pred(n,k_i)))
print("="*10)