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
07d60570
Commit
07d60570
authored
4 years ago
by
rjm432
Browse files
Options
Downloads
Patches
Plain Diff
logic gates module
parent
40bcfb67
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
logic_gates.py
+49
-0
49 additions, 0 deletions
logic_gates.py
with
49 additions
and
0 deletions
logic_gates.py
0 → 100644
+
49
−
0
View file @
07d60570
# Ryan McShane
# Logic Gates Modules
# AND, OR, XOR, NAND, NOR, XNOR
def
and
(
circuit
,
A
,
B
,
result
):
circuit
.
ccx
(
q
[
A
],
q
[
B
],
q
[
result
])
def
or
(
circuit
,
A
,
B
,
result
):
circuit
.
x
(
q
[
A
])
circuit
.
x
(
q
[
B
])
circuit
.
ccx
(
q
[
result
])
circuit
.
x
(
q
[
result
])
circuit
.
x
(
q
[
B
])
circuit
.
x
(
q
[
A
])
def
nand
(
circuit
,
A
,
B
,
result
):
circuit
.
ccx
(
q
[
A
],
q
[
B
],
q
[
result
])
circuit
.
x
(
q
[
result
])
def
nor
(
circuit
,
A
,
B
,
result
):
circuit
.
x
(
q
[
A
])
circuit
.
x
(
q
[
B
])
circuit
.
ccx
(
q
[
result
])
circuit
.
x
(
q
[
B
])
circuit
.
x
(
q
[
A
])
def
xor
(
circuit
,
A
,
B
,
result
,
t1
,
t2
,
t3
):
nand
(
circuit
,
q
[
A
],
q
[
B
],
q
[
t1
])
circuit
.
x
(
q
[
t1
])
nand
(
circuit
,
q
[
A
],
q
[
t1
],
q
[
t2
])
circuit
.
x
(
q
[
t2
])
nand
(
circuit
,
q
[
B
],
q
[
t1
],
q
[
t3
])
circuit
.
x
(
q
[
t3
])
nand
(
circuit
,
q
[
t2
],
q
[
t3
],
q
[
result
])
circuit
.
x
(
q
[
result
])
circuit
.
x
(
q
[
t3
])
nand
(
circuit
,
q
[
B
],
q
[
t1
],
q
[
t3
])
circuit
.
x
(
q
[
t2
])
nand
(
circuit
,
q
[
A
],
q
[
t1
],
q
[
t2
])
circuit
.
x
(
q
[
t1
])
nand
(
circuit
,
q
[
A
],
q
[
B
],
q
[
t1
])
def
xnor
(
circuit
,
a
,
b
,
result
,
R
,
At
,
Bt
):
xor
(
circuit
,
a
,
b
,
result
,
R
,
At
,
Bt
)
circuit
.
x
(
q
[
result
])
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