-
Notifications
You must be signed in to change notification settings - Fork 0
/
superdanceCoding.py
52 lines (35 loc) · 993 Bytes
/
superdanceCoding.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
#!/usr/bin/env python
# coding: utf-8
# In[270]:
from qiskit import *
from qiskit.tools.visualization import plot_bloch_multivector, plot_histogram, array_to_latex
from math import pi
get_ipython().run_line_magic('matplotlib', 'inline')
# In[ ]:
circuit = QuantumCircuit(2)
#prepare the bell state and distribute qubites
circuit.h(0)
circuit.cx(0, 1)
circuit.barrier()
# Olivia encodes her message and transmites her qubits to barron
match message := '11': #The message
case '00':
circuit.id(0)
case '01':
circuit.z(0)SSS
case '10':
circuit.x(0)
case '11':
circuit.z(0)
circuit.x(0)
circuit.barrier()
#Barron decodes Olivia 's message
circuit.cx(0,1)
circuit.h(0)
#Barron measures the qubits to read Olivia's message
circuit.measure_all()
circuit.draw(output='mpl')
# In[ ]:
simulator = Aer.get_backend('qasm_simulator')
result = execute(circuit, backend=simulator).result()
plot_histogram(result.get_counts())