Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit 4db4659

Browse files
committed
Fix task numbers and add kata magic commands to the Jupyter notebook
1 parent d50e936 commit 4db4659

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

KeyDistribution_E91/KeyDistribution_E91.ipynb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"cell_type": "code",
3232
"execution_count": null,
3333
"source": [
34+
"%kata T11_EntangledPairst\n",
35+
"\n",
3436
"operation EntangledPairs (qsAlice : Qubit[], qsBob : Qubit[]) : Unit is Adj{\n",
3537
" Fact(Length(qsAlice) == Length(qsBob), \"Alice and Bob should have the same number of qubits\");\n",
3638
" // ...\n",
@@ -107,6 +109,8 @@
107109
"cell_type": "code",
108110
"execution_count": null,
109111
"source": [
112+
"%kata T21_RotateAndMeasure\n",
113+
"\n",
110114
"operation RotateAndMeasure(q : Qubit, basisIndex: Int) : Result {\n",
111115
" // ...\n",
112116
"\n",
@@ -147,6 +151,8 @@
147151
"cell_type": "code",
148152
"execution_count": null,
149153
"source": [
154+
"%kata T22_RandomBasesArray\n",
155+
"\n",
150156
"operation RandomBasesArray (basesIndices: Int[], N: Int) : Int[] {\n",
151157
" // ...\n",
152158
"\n",
@@ -174,6 +180,8 @@
174180
"cell_type": "code",
175181
"execution_count": null,
176182
"source": [
183+
"%kata T23_MeasureQubitArray\n",
184+
"\n",
177185
"operation MeasureQubitArray (qs: Qubit[], basesIndices: Int[]) : Result[] {\n",
178186
" // ...\n",
179187
"\n",
@@ -203,6 +211,8 @@
203211
"cell_type": "code",
204212
"execution_count": null,
205213
"source": [
214+
"%kata T24_GenerateSharedKey\n",
215+
"\n",
206216
"function GenerateSharedKey (basesAlice: Int[], basesBob: Int[], results: Result[]) : Bool[] {\n",
207217
" let key = new Bool[0];\n",
208218
" // ...\n",
@@ -226,7 +236,7 @@
226236
"cell_type": "code",
227237
"execution_count": null,
228238
"source": [
229-
"operation T24_E91Protocol () : Unit {\n",
239+
"operation T25_E91Protocol () : Unit {\n",
230240
" // 1. Alice and Bob are distributed arrays of entangled pairs\n",
231241
"\n",
232242
" // 2. Alice and Bob choose random measurement bases\n",
@@ -244,7 +254,7 @@
244254
"cell_type": "code",
245255
"execution_count": null,
246256
"source": [
247-
"%simulate T24_E91Protocol"
257+
"%simulate T25_E91Protocol"
248258
],
249259
"outputs": [],
250260
"metadata": {}
@@ -283,6 +293,8 @@
283293
"cell_type": "code",
284294
"execution_count": null,
285295
"source": [
296+
"%kata T31_CorrelationCheck\n",
297+
"\n",
286298
"function CorrelationCheck(basesAlice: Int[], basesBob: Int[], resultsAlice: Result[], resultsBob: Result[]) : Double {\n",
287299
" // ...\n",
288300
"\n",
@@ -323,6 +335,8 @@
323335
"cell_type": "code",
324336
"execution_count": null,
325337
"source": [
338+
"%kata T32_Eavesdrop\n",
339+
"\n",
326340
"operation Eavesdrop (qAlice : Qubit, qBob : Qubit, basisIndex : Int) : (Result, Result) {\n",
327341
" Fact(basisIndex == 2 or basisIndex == 3, \"Eve should measure in one of Alice's and Bob's compatible basis\");\n",
328342
" // ...\n",

KeyDistribution_E91/ReferenceImplementation.qs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ namespace Quantum.Kata.KeyDistributionE91 {
164164
}
165165

166166
// Task 3.3. Catch the eavesdropper
167-
operation T32_E91ProtocolWithEavesdropper_Reference () : Unit {
167+
operation T33_E91ProtocolWithEavesdropper_Reference () : Unit {
168168
// 1. Alice and Bob are distributed arrays of entangled pairs
169169
let N = 10;
170170
use (qsAlice, qsBob) = (Qubit[N] ,Qubit[N]);

KeyDistribution_E91/Tests.qs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace Quantum.Kata.KeyDistributionE91 {
3131

3232
AssertAllZero(qsAlice + qsBob);
3333
}
34+
3435

3536
//////////////////////////////////////////////////////////////////
3637
// Part II. E91 Protocol
@@ -50,7 +51,6 @@ namespace Quantum.Kata.KeyDistributionE91 {
5051
}
5152
Reset(q);
5253
}
53-
5454
}
5555

5656
@Test("QuantumSimulator")
@@ -61,7 +61,7 @@ namespace Quantum.Kata.KeyDistributionE91 {
6161
let basesArray = RandomBasesArray(basesIndices, N);
6262
EqualityFactI(
6363
Length(basesArray), N,
64-
"Generated array length does not match the input length"
64+
$"Generated array should be of length {N}"
6565
);
6666

6767
for i in basesArray {
@@ -125,11 +125,11 @@ namespace Quantum.Kata.KeyDistributionE91 {
125125
);
126126
}
127127

128+
128129
//////////////////////////////////////////////////////////////////
129130
// Part III. Eavesdropping
130131
//////////////////////////////////////////////////////////////////
131132

132-
133133
@Test("QuantumSimulator")
134134
function T31_CorrelationCheck() : Unit {
135135
// ...

0 commit comments

Comments
 (0)