microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
katas/content/oracles/bit_pattern_challenge/index.md
27lines · modecode
| 1 | **Inputs:** |
| 2 | |
| 3 | 1. $N$ qubits in an arbitrary state $|x\rangle$ (input/query register). |
| 4 | 2. A boolean array of length $N$ `pattern` representing a basis state; `true` and `false` elements correspond to $|1\rangle$ and $|0\rangle$, respectively. |
| 5 | |
| 6 | **Goal:** |
| 7 | |
| 8 | Flip the sign of the input state $|x\rangle$ if the input register matches the basis state |
| 9 | represented by `pattern`. |
| 10 | **Implement this oracle without using auxiliary qubits** |
| 11 | |
| 12 | **Examples:** |
| 13 | |
| 14 | * If the query register is in the state $|010\rangle$ and `pattern = [false, true, false]`, flip the sign of the input register. |
| 15 | * If the query register is in the state $|1001\rangle$ and `pattern = [false, true, true, false]`, do nothing. |
| 16 | |
| 17 | <br/> |
| 18 | <details> |
| 19 | <summary><b>Before implementing this oracle, answer the question: are you implementing a marking or a phase oracle?</b></summary> |
| 20 | This is a phase oracle, because we are changing the phase of the input state $|x\rangle$ based on the value of the function $f(x)$. |
| 21 | </details> |
| 22 | |
| 23 | <br/> |
| 24 | <details> |
| 25 | <summary><b>Need a hint?</b></summary> |
| 26 | Can you transform the state of the input register based on the <code>pattern</code> value so as to have to flip the phase only for the $|1...1\rangle$ state? |
| 27 | </details> |
| 28 | |