Alfa 0b0001 0b0010 0b0011 0b0100 0b0101 0b0110 0b0111 0b1000 0b1001 0b

 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
Alfa = [0b0001, 0b0010, 0b0011, 0b0100, 0b0101, 0b0110, 0b0111,
0b1000, 0b1001, 0b1010, 0b1011, 0b1100, 0b1101, 0b1110, 0b1111]
Betta = [0b001, 0b010, 0b011, 0b100, 0b101, 0b110, 0b111]
Betta3 = [0b001, 0b010, 0b011]
Vh = [0b0000, 0b0001, 0b0010, 0b0011, 0b0100, 0b0101, 0b0110, 0b0111,
0b1000, 0b1001, 0b1010, 0b1011, 0b1100, 0b1101, 0b1110, 0b1111]
TabS1 = {0b0000: 0b0011, 0b0001: 0b0101, 0b0010: 0b0110, 0b0011: 0b0100, 0b0100: 0b0101,
0b0101: 0b0001, 0b0110: 0b0010, 0b0111: 0b0101,
0b1000: 0b0111, 0b1001: 0b0110, 0b1010: 0b0010, 0b1011: 0b0011, 0b1100: 0b0111, 0b1101: 0b0100,
0b1110: 0b0001, 0b1111: 0b0011}
TabS2 = {0b0000: 0b0001, 0b0001: 0b0110, 0b0010: 0b0111, 0b0011: 0b0100, 0b0100: 0b0100,
0b0101: 0b0010, 0b0110: 0b0110, 0b0111: 0b0010,
0b1000: 0b0011, 0b1001: 0b0100, 0b1010: 0b0011, 0b1011: 0b0001, 0b1100: 0b0101, 0b1101: 0b0111,
0b1110: 0b0011, 0b1111: 0b0101}
TabS3 = {0b0000: 0b0001, 0b0001: 0b0011, 0b0010: 0b0001, 0b0011: 0b0011, 0b0100: 0b0011,
0b0101: 0b0010, 0b0110: 0b0010, 0b0111: 0b0010,
0b1000: 0b0010, 0b1001: 0b0010, 0b1010: 0b0001, 0b1011: 0b0011, 0b1100: 0b0011, 0b1101: 0b0001,
0b1110: 0b0011, 0b1111: 0b0001}
def make_tabs(tab_number):
'''f = open("resulttab" + str(tab_number) + ".txt", "a")
f.write('Alfa Betta Count' + '\n')'''
for i in range(0, len(Alfa)):
for l in range(0, len(Betta)):
countt = 0
res1 = 0b0000
res2 = 0b0000
for j in range(0, len(Vh)):
if str(tab_number) == '1':
Vi = (TabS1[Vh[j]])
elif str(tab_number) == '2':
Vi = (TabS2[Vh[j]])
else:
break
temp1 = Vh[j] & Alfa[i]
temp2 = Vi & Betta[l]
for k in range(0,4):
res1 = res1^(temp1 >> k) & 1
for k in range(0,3):
res2 = res2^(temp2 >> k) & 1
if res1 == res2:
countt = countt + 1
'''if countt <= 4 or countt >= 12:
f.write(str(bin(Alfa[i])) + '\t' + str(bin(Betta[l])) + '\t' + str(countt) + '\n')
f.close()'''
def make_tab3():
f = open("resulttab3.txt", "a")
f.write('Alfa Betta Count' + '\n')
for i in range(0, len(Alfa)):
for l in range(0, len(Betta3)):
countt = 0
res1 = 0b0000
res2 = 0b0000
for j in range(0, len(Vh)):
Vi = (TabS3[Vh[j]])
temp1 = Vh[j] & Alfa[i]
temp2 = Vi & Betta3[l]
print temp1, temp2
for k in range(0,4):
res1 = res1^(temp1 >> k) & 1
for k in range(0,3):
res2 = res2^(temp2 >> k) & 1
print res1, res2
if res1 ^ res2 == 0:
countt = countt + 1
if countt <= 4 or countt >= 12:
f.write(str(bin(Alfa[i])) + '\t' + str(bin(Betta[l])) + '\t' + str(countt) + '\n')
f.close()
make_tabs(1)
make_tabs(2)
'''make_tab3()'''