microsoft/qdk

Public

mirrored from https://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/distinguishing_states/four_orthogonal_two_qubit/Verification.qs

38lines · modecode

1namespace Kata.Verification {
2 open Microsoft.Quantum.Katas;
3
4 // 0 - (|00⟩ + |01⟩ + |10⟩ + |11⟩) / 2
5 // 1 - (|00⟩ - |01⟩ + |10⟩ - |11⟩) / 2
6 // 2 - (|00⟩ + |01⟩ - |10⟩ - |11⟩) / 2
7 // 3 - (|00⟩ - |01⟩ - |10⟩ + |11⟩) / 2
8 operation StatePrep_TwoQubitState(
9 qs : Qubit[],
10 state : Int,
11 dummyVar : Double
12 ) : Unit is Adj {
13 StatePrep_BasisStateMeasurement(qs, state, dummyVar);
14
15 H(qs[0]);
16 H(qs[1]);
17 }
18
19 @EntryPoint()
20 operation CheckSolution() : Bool {
21 let isCorrect = DistinguishStates_MultiQubit(
22 2,
23 4,
24 StatePrep_TwoQubitState,
25 Kata.TwoQubitState,
26 false,
27 ["(|00⟩ + |01⟩ + |10⟩ + |11⟩) / 2", "(|00⟩ - |01⟩ + |10⟩ - |11⟩) / 2", "(|00⟩ + |01⟩ - |10⟩ - |11⟩) / 2", "(|00⟩ - |01⟩ - |10⟩ + |11⟩) / 2"]
28 );
29
30 if not isCorrect {
31 Message("Incorrect.");
32 } else {
33 Message("Correct!");
34 }
35
36 return isCorrect
37 }
38}
39