Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tcNickolas authored Apr 22, 2024
1 parent 112e89a commit dceb420
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions katas/content/superposition/four_bitstrings/Verification.qs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Kata.Verification {
@EntryPoint()
operation CheckSolution() : Bool {

mutable bits = [[false, false], [false, true], [true, false], [true, true]];
let bits = [[false, false], [false, true], [true, false], [true, true]];
Message($"Testing for bits = {bits}...");
if not CheckOperationsEquivalenceOnZeroStateWithFeedback(
Kata.FourBitstringSuperposition(_, bits),
Expand All @@ -39,14 +39,13 @@ namespace Kata.Verification {
return false;
}

mutable bitstrings = [
let bitstrings = [
[[false, true, false], [true, false, false], [false, false, true], [true, true, false]],
[[true, false, false], [false, false, true], [false, true, false], [true, true, true]],
[[false, false, false], [false, true, false], [true, true, false], [true, false, true]]
];

for i in 0 .. Length (bitstrings) - 1 {
let bitstring = bitstrings[i];
for bitstring in bitstrings {
Message($"Testing for bits = {bitstring}...");
if not CheckOperationsEquivalenceOnZeroStateWithFeedback(
Kata.FourBitstringSuperposition(_, bitstring),
Expand Down
4 changes: 2 additions & 2 deletions katas/content/superposition/four_bitstrings/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
**Inputs:**

1. $N$ qubits in the $|0 \dots 0\rangle$ state.
2. Four bit string represented as `Bool[][]` `bits`.
2. Four bit strings represented as `Bool[][]` `bits`.

`bits` is an array of size $4 * N$ which describes the bit strings as follows:
`bits` is an array of size $4 \times N$ which describes the bit strings as follows:
- `bits[i]` describes the *i*th bit string and has $N$ elements.
- All four bit strings will be distinct.

Expand Down
4 changes: 2 additions & 2 deletions katas/content/superposition/four_bitstrings/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ We will uncompute each of them separately, so one of the auxiliary qubits will b
"codePath": "./SolutionA.qs"
})

We are going to leverage the recursion abilities of Q# to create a superposition of the four bit strings. This solution also extends to an arbitrary number of bit strings with no code changes.
Alternatively, we can leverage the recursion abilities of Q# to create a superposition of the four bit strings. This solution also extends to an arbitrary number of bit strings with no code changes.

For this process we will look at the first bits of each string and adjust the probability of measuring a $|0\rangle$ or $|1\rangle$ accordingly on the first qubit of our answer. We will then recursively call (as needed) the process again to adjust the probabilities of measurement on the second bit depending on the first bit. This process recurses until no more input bits are provided.

Consider for example the following four bit strings on which to create a superposition: $|001\rangle, |101\rangle, |111\rangle, |110\rangle$.
Consider, for example, the following four bit strings on which to create a superposition: $|001\rangle, |101\rangle, |111\rangle, |110\rangle$.

We can rewrite the superposition state we need to prepare as

Expand Down
2 changes: 1 addition & 1 deletion katas/content/superposition/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ This kata is designed to get you familiar with the concept of superposition and

@[exercise]({
"id": "superposition__four_bitstrings",
"title": "Four Bitstrings",
"title": "Four Bit Strings",
"path": "./four_bitstrings/",
"qsDependencies": [
"../KatasLibrary.qs",
Expand Down

0 comments on commit dceb420

Please sign in to comment.