-
Notifications
You must be signed in to change notification settings - Fork 0
/
thlr_1_code.py
91 lines (71 loc) · 1.15 KB
/
thlr_1_code.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#[Q9]
def union(E,F):
L=list(E)
M = list(F)
for i in range (len(M)):
l = len(L)
j = 0
while j!=l and L[j]!=M[i]:
j+=1
if j == l:
L.append(M[i])
return set(L)
#[/Q9]
#[Q10]
def intersection(E, F):
L = list(E)
M = list(F)
N=[]
for i in range (len(M)):
l = len(L)
j = 0
while j!=l and L[j]!=M[i]:
j+=1
if j != l:
N.append(M[i])
return set(L)
#[/Q10]
#[Q11]
def substraction(E,F):
L=list(E)
M = list(F)
for i in range (len(M)):
l = len(L)
j = 0
while j!=l and L[j]!=M[i]:
j+=1
if j != l:
L.remove(M[i])
return set(L)
#[/Q11]
#[Q12]
def diff(E,F):
L=list(E)
M = list(F)
for i in range (len(M)):
l = len(L)
j = 0
while j!=l and L[j]!=M[i]:
j+=1
if j != l:
L.remove(M[i])
else:
L.append(M[i])
return set(L)
#[/Q12]
#[Q13]
def sublist(L):
if len(L) == 0:
return [[]]
liste = []
for i in sublist(L[1:]):
liste += [i, [L[0]]+i]
return liste
#[/Q13]
#[Q14]
def power_set(E):
M= sublist(list(E))
for i in range (len (M)):
M[i]=set(M[i])
return M
#[/Q14]