This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
hello_qiskit.py
119 lines (116 loc) · 4.04 KB
/
hello_qiskit.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
110
111
112
113
114
115
116
117
118
119
import hello_quantum
exercises = [
{
'initialize': [],
'success_condition': {},
'allowed_gates': {'0': {'x': 3}, '1': {}, 'both': {}},
'vi': [[1], True, False],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['h','0']],
'success_condition': {},
'allowed_gates': {'0': {'h': 3}, '1': {}, 'both': {}},
'vi': [[1], True, False],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['x','0'],['h','0']],
'success_condition': {},
'allowed_gates': {'0': {'ry(pi/4)': 4}, '1': {}, 'both': {}},
'vi': [[1], True, False],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['x','0'],['h','0']],
'success_condition': {},
'allowed_gates': {'0': {'bloch':0, 'ry(pi/4)': 4}, '1': {}, 'both': {}},
'vi': [[1], True, False],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['x','0'],['h','0']],
'success_condition': {},
'allowed_gates': {'1': {'bloch':0,'x':2,'h':2,'ry(pi/4)': 2}, '0': {}, 'both': {}},
'vi': [[0], True, False],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['x','0']],
'success_condition': {'XX':1},
'allowed_gates': {'0': {'bloch':0,'x':0,'h':0,'ry(pi/4)': 0}, '1': {'bloch':0,'x':0,'h':0,'ry(pi/4)': 0}, 'both': {}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['ry(-pi/4)','1']],
'success_condition': {},
'allowed_gates': {'0': {'x': 3}, '1': {}, 'both': {}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['ry(-pi/4)','1']],
'success_condition': {},
'allowed_gates': {'0': {'h': 3}, '1': {}, 'both': {}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [],
'success_condition': {'ZI':-1, 'IZ':-1},
'allowed_gates': {'0': {'bloch':0,'ry(pi/4)': 0}, '1': {'bloch':0,'ry(pi/4)': 0}, 'both': {}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['h','0'],['h','1']],
'success_condition': {},
'allowed_gates': {'0': {}, '1': {}, 'both': {'cz':3}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [['h','0'],['h','1']],
'success_condition': {},
'allowed_gates': {'0': {}, '1': {}, 'both': {'cz':3}},
'vi': [[], True, True],
'mode': 'y',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [],
'success_condition': {'ZZ':2},
'allowed_gates': {'0': {'bloch':0, 'x':0, 'h':0, 'cz':0, 'ry(pi/4)': 0}, '1': {'bloch':0, 'x':0, 'h':0, 'cz':0, 'ry(pi/4)': 0}, 'both': {'cz':0}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'q[0]', '1':'q[1]'}
},
{
'initialize': [],
'success_condition': {'ZZ':+0.7071,'ZX':+0.7071,'XZ':+0.7071,'XX':-0.7071},
'allowed_gates': {'0': {'bloch':0, 'x':0, 'h':0, 'cz':0, 'ry(pi/4)': 0}, '1': {'bloch':0, 'x':0, 'h':0, 'cz':0, 'ry(pi/4)': 0}, 'both': {'cz':0}},
'vi': [[], True, True],
'mode': 'line',
'qubit_names': {'0':'A', '1':'B'}
}
]
def run_puzzle(j):
puzzle = hello_quantum.run_game(exercises[j]['initialize'],
exercises[j]['success_condition'],
exercises[j]['allowed_gates'],
exercises[j]['vi'],
qubit_names=exercises[j]['qubit_names'],
mode=exercises[j]['mode']
)
return puzzle