microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.2.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/oracles/kth_bit_oracle/Verification.qs

24lines · modecode

1namespace Kata.Verification {
2 operation KthBit_Oracle_Reference(x : Qubit[], k : Int) : Unit is Adj + Ctl {
3 Z(x[k]);
4 }
5
6 @EntryPoint()
7 operation CheckSolution() : Bool {
8 for N in 1..5 {
9 for k in 0..(N-1) {
10 let isCorrect = CheckOperationsEqualReferenced(
11 N,
12 Kata.KthBit_Oracle(_, k),
13 KthBit_Oracle_Reference(_, k));
14 if not isCorrect {
15 Message($"Failed on test case for NumberOfQubits = {N}, k = {k}.");
16 return false;
17 }
18 }
19 }
20 Message("All tests passed.");
21 true
22 }
23
24}
25