microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
alex/pythontelem

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/grovers_search/reflection_about_state/Solution.qs

23lines · modecode

1namespace Kata {
2 open Microsoft.Quantum.Math;
3
4 operation ReflectionAboutState(
5 qs : Qubit[],
6 statePrep : Qubit[] => Unit is Adj + Ctl)
7 : Unit is Adj + Ctl {
8 within {
9 Adjoint statePrep(qs);
10 } apply {
11 ConditionalPhaseFlip(qs);
12 }
13 }
14
15 operation ConditionalPhaseFlip(qs : Qubit[]) : Unit is Adj + Ctl {
16 within {
17 ApplyToEachA(X, qs);
18 } apply {
19 Controlled Z(qs[1 ...], qs[0]);
20 }
21 R(PauliI, 2.0 * PI(), qs[0]);
22 }
23}
24