-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
62 lines (54 loc) · 1.46 KB
/
main.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
import Absorbator
import Includer
import BoolFunc
def vectorFromBits(inp):
return [v == '1' for v in inp if v in ['0', '1']]
def readFromFile(filename):
vectors = list()
f = open(filename, 'r')
for line in f:
vectors.append(vectorFromBits(line))
f.close()
return vectors
def vectorToStr(vector):
result = ''
for v in vector:
if v: result += '1'
else: result += '0'
return result
def test():
bf = BoolFunc.BoolFunc()
vector = vectorFromBits('0' + '1' * 126 + '0')
bf.setFromVector(vector)
a = Absorbator.Absorbator(bf)
print('Start absorbator')
a.absorb()
print(a.bf)
inc = Includer.Includer(a.bf)
print('Start includer')
inc.simplify()
print(inc.bf)
s = input('Press any key for exit...')
def main():
vectors = readFromFile('input.txt')
bf = BoolFunc.BoolFunc()
ab, inc = None, None
for vector in vectors:
print('Function')
print(vectorToStr(vector))
bf.setFromVector(vector)
ab = Absorbator.Absorbator(bf)
print('Start absorbator')
ab.absorb()
print(ab.bf)
inc = Includer.Includer(ab.bf)
print('Start includer')
inc.simplify()
print(inc.bf)
print()
print('Answer')
print(inc.bf)
print()
s = input('Press any key for exit...')
if __name__ == '__main__':
main()