Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Classical to Quantum
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rjm432
Classical to Quantum
Commits
76ce816e
Commit
76ce816e
authored
5 years ago
by
rjm432
Browse files
Options
Downloads
Patches
Plain Diff
completed
parent
64569d4c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
1/1_c.py
+36
-4
36 additions, 4 deletions
1/1_c.py
with
36 additions
and
4 deletions
1/1_c.py
+
36
−
4
View file @
76ce816e
...
...
@@ -13,23 +13,55 @@ XOR
'''
#Quantum Wires
q
=
QuantumRegister
(
3
,
'
q
'
)
q
=
QuantumRegister
(
6
,
'
q
'
)
#Classical Wires
c
=
ClassicalRegister
(
3
,
'
c
'
)
#Build Circuit
circ
=
QuantumCircuit
(
q
,
c
)
#Inputs
circ
.
x
(
q
[
0
])
circ
.
x
(
q
[
1
])
#Wire assignments
'''
q[0] = A
q[1] = B
q[2] = C
q[3] = At(emp)
q[4] = Bt(emp)
q[5] = R(esult)
'''
#Circuit
circ
.
barrier
(
q
[
0
],
q
[
1
],
q
[
2
])
circ
.
ccx
(
q
[
0
],
q
[
1
],
q
[
2
])
circ
.
x
(
q
[
2
])
# First NAND Gate comparing A and B
circ
.
ccx
(
q
[
0
],
q
[
2
],
q
[
3
])
circ
.
x
(
q
[
3
])
# Second NAND Gate comparing C and A
circ
.
ccx
(
q
[
2
],
q
[
1
],
q
[
4
])
circ
.
x
(
q
[
4
])
# Third NAND Gate comparing C and B
circ
.
ccx
(
q
[
3
],
q
[
4
],
q
[
5
])
circ
.
x
(
q
[
5
])
# Fourth and Final NAND Gate comparing At and Bt
#Measure
circ
.
barrier
(
q
[
0
],
q
[
1
],
q
[
2
],
q
[
3
],
q
[
4
],
q
[
5
])
circ
.
measure
(
q
[
0
],
c
[
0
])
circ
.
measure
(
q
[
1
],
c
[
1
])
circ
.
measure
(
q
[
5
],
c
[
2
])
#Text Representation
x
=
text
=
circ
.
draw
(
output
=
'
text
'
)
print
(
text
)
#Test and Results
backend_sim
=
BasicAer
.
get_backend
(
'
qasm_simulator
'
)
job_sim
=
execute
(
circ
,
backend_sim
,
shots
=
2048
)
result_sim
=
job_sim
.
result
()
counts
=
result_sim
.
get_counts
()
print
(
counts
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment