-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathHame Zir Majmooe Ha.py
70 lines (49 loc) · 1.26 KB
/
Hame Zir Majmooe Ha.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# همه ی زیرمجموعه ها
# ID : 12912
# https://quera.org/problemset/12912/
# https://b2n.ir/e36183
from collections import deque
h = []
def printPowerSet(S, i, out=deque()):
if i < 0:
po = list(out)
po.sort()
h.append(po)
return
out.append(S[i])
printPowerSet(S, i - 1, out)
out.pop()
while i > 0 and S[i] == S[i - 1]:
i = i - 1
printPowerSet(S, i - 1, out)
def findPowerSet(S):
S.sort()
printPowerSet(S, len(S) - 1)
haaayyyyy = int(input())
s = [int(u) for u in range(1, haaayyyyy + 1)]
printPowerSet(s, haaayyyyy - 1)
h.sort()
for k in h:
st = str(k)
st = st.replace("[", "{")
st = st.replace("]", "}")
print(st)
###########################################################
def sebSequence(number, step, keep, continuee):
if step > number:
return
if continuee:
printer(keep)
keep.append(step + 1)
sebSequence(number, step + 1, keep, True)
keep.pop()
sebSequence(number, step + 1, keep, False)
def printer(keep):
temp = []
for i in range(len(keep)):
temp.append(keep[i])
text = '{' + f'{", ".join([str(i) for i in temp])}' + '}'
print(text)
number = int(input())
keep = []
sebSequence(number, 0, keep, True)