microsoft/qdk

Public

mirrored fromhttps://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
billt/revert-mimalloc

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

katas/content/oracles/bit_pattern_challenge/solution.md

9lines · modepreview

The easiest solution is to transform the given state so that the basis state that matches the given pattern becomes $|1...1\rangle$,
apply the Controlled $Z$ gate to flip the phase of just that basis state, and then uncompute to make sure that only the relative phases of the basis states change, not the basis states themselves. 

You can use the `within ... apply` construct to automate uncomputation.

@[solution]({
    "id": "oracles__bit_pattern_challenge_solution",
    "codePath": "Solution.qs"
})