microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/replace-qsharp-with-qdk-python-tests

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/getting_started/flip_qubit/Verification.qs

27lines · modecode

1namespace Kata.Verification {
2 import KatasUtils.*;
3 import Std.Diagnostics.*;
4
5 operation FlipQubit(q : Qubit) : Unit is Adj + Ctl {
6 X(q);
7 }
8
9 operation CheckSolution() : Bool {
10 let solution = register => Kata.FlipQubit(register[0]);
11 let reference = register => FlipQubit(register[0]);
12 let isCorrect = CheckOperationsAreEqual(1, solution, reference);
13
14 // Output different feedback to the user depending on whether the solution was correct.
15 if isCorrect {
16 Message("Correct!");
17 Message("Congratulations! You have solved your first exercise.");
18 } else {
19 Message("Incorrect.");
20 Message("Look out for hints when your solution is incorrect.");
21 Message("Hint: examine the effect your solution has on the |0〉 state and compare it with the effect it " +
22 "is expected to have.");
23 ShowQuantumStateComparison(1, (qs => ()), solution, reference);
24 }
25 isCorrect
26 }
27}
28