-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grover.py
109 lines (74 loc) · 1.49 KB
/
Grover.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from qiskit import QuantumRegister, ClassicalRegister
from qiskit import QuantumCircuit, Aer, execute
q1 = QuantumRegister(10)
c1 = ClassicalRegister(10)
qc1 = QuantumCircuit(q1, c1)
# qc1.h(q[0])
# qc1.cx(q[0], q[1])
# qc1.measure(q, c)
#Make alghoritm
# qc1.x(q1[0])
# qc1.x(q1[5])
#
qc1.x(q1[1])
qc1.x(q1[6])
qc1.h(q1[1])
qc1.h(q1[6])
qc1.h(q1[9])
qc1.x(q1[1])
qc1.ccx(q1[0], q1[1], q1[2])
qc1.x(q1[0])
qc1.x(q1[1])
qc1.ccx(q1[0], q1[1], q1[3])
qc1.x(q1[0])
qc1.x(q1[6])
qc1.ccx(q1[5], q1[6], q1[7])
qc1.x(q1[5])
qc1.x(q1[6])
qc1.ccx(q1[5], q1[6], q1[8])
qc1.x(q1[5])
qc1.ccx(q1[2], q1[3], q1[4])
qc1.ccx(q1[7], q1[4], q1[2])
qc1.ccx(q1[8], q1[4], q1[3])
#---------------
qc1.ccx(q1[3], q1[4], q1[9])
#---------------
qc1.h(q1[1])
qc1.h(q1[6])
qc1.h(q1[9])
qc1.x(q1[1])
qc1.ccx(q1[0], q1[1], q1[2])
qc1.x(q1[0])
qc1.x(q1[1])
qc1.ccx(q1[0], q1[1], q1[3])
qc1.x(q1[0])
qc1.x(q1[6])
qc1.ccx(q1[5], q1[6], q1[7])
qc1.x(q1[5])
qc1.x(q1[6])
qc1.ccx(q1[5], q1[6], q1[8])
qc1.x(q1[5])
qc1.ccx(q1[2], q1[3], q1[4])
qc1.ccx(q1[7], q1[4], q1[2])
qc1.ccx(q1[8], q1[4], q1[3])
qc1.h(q1[1])
qc1.x(q1[1])
qc1.h(q1[6])
qc1.x(q1[6])
qc1.h(q1[6])
qc1.cx(q1[1], q1[6])
qc1.x(q1[1])
qc1.h(q1[1])
qc1.h(q1[6])
qc1.x(q1[6])
qc1.h(q1[6])
qc1.h(q1[9])
# #Measure
# for i in range(10):
# qc1.measure(q1[i], c1[i])
qc1.measure(q1[1], c1[1])
qc1.measure(q1[6], c1[6])
backend = Aer.get_backend('qasm_simulator')
job_sim = execute(qc1, backend)
sim_result = job_sim.result()
print(sim_result.get_counts(qc1))