-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
84 lines (78 loc) · 1.91 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from fraction import *
from gates import *
from gates.cicuit import Circuit
from gates.two_split_gate import TwoWaySplitGate
import time
x = Fraction(1, 2)
x.show()
y = Fraction(2, 3)
print(y)
print(x + y)
print(y - x)
print(x * y)
print(y/x)
print(x == y)
print(x > y)
print(x < y)
#Logic Gates
#
# g1 = AndGate("G1")
# print(g1.get_output())
#
#
#
# g2 = OrGate("G2")
# print(g2.get_output())
#
#
#
# g3 = NotGate("G3")
# print(g3.get_output())
#
# g1 = AndGate("G1")
# g2 = AndGate("G2")
# g3 = OrGate("G3")
# g4 = NotGate("G4")
# g5 = NorGate("G5")
# g6 = NandGate("G6")
# c1 = Connector(g1, g3)
# c2 = Connector(g2, g3)
# c3 = Connector(g3, g4)
#
#
# print(g4.get_output())
# print(g5.get_output())
# print(g6.get_output())
#
# #
# g7=AndGate("G7")
# g8=AndGate("G8")
# g9=NorGate("G9")
# c4=Connector(g7,g9)
# c5=Connector(g8,g9)
# print(g9.get_output())
# #
# split=TwoWaySplitGate("Split")
# andGate=AndGate("And")
# c1=Connector(split,andGate)
# c2=Connector(split,andGate)
#
# print(andGate.get_output())
print(sum_of_n(10))
for i in range(5):
print("Sum is %d required %10.7f seconds" % sum_of_n_2(100000))
print("Other Algorithm")
for i in range(5):
print("Sum is %d required %10.7f seconds" % sum_of_n_3(10**100))
coll=[0,5,6,7,7,100,-4500,-10000,100000]
print("Min is %d required %10.7f seconds" % findMinLin(coll))
print("Min is %d required %10.7f seconds" % findMinQuad(coll))
print(anagram_solution_1("apple", "pleap")) # expected: True
print(anagram_solution_1("abcd", "dcba")) # expected: True
print(anagram_solution_1("abcd", "dcda")) # expected: False
print(anagram_solution_2("apple", "pleap")) # expected: True
print(anagram_solution_2("abcd", "dcba")) # expected: True
print(anagram_solution_2("abcd", "dcda")) # expected: False
print(anagram_solution_4("apple", "pleap")) # expected: True
print(anagram_solution_4("abcd", "dcba")) # expected: True
print(anagram_solution_4("abcd", "dcda")) # expected: False