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/marking_oracles/pattern_match/Verification.qs

31lines · modecode

1namespace Kata.Verification {
2 open Microsoft.Quantum.Katas;
3
4 function F_PatternMatching(args : Bool[], a : Int[], r : Bool[]) : Bool {
5 for i in 0 .. Length(a) - 1 {
6 if args[a[i]] != r[i] {
7 return false;
8 }
9 }
10 return true;
11 }
12
13 @EntryPoint()
14 operation CheckSolution() : Bool {
15 for (n, a, r) in [
16 (2, [], []),
17 (2, [1], [true]),
18 (3, [0, 2], [false, true]),
19 (4, [1, 3], [true, false]),
20 (5, [0, 1, 4], [true, true, false])
21 ] {
22 if not CheckOracleImplementsFunction(n, Kata.Oracle_PatternMatching(_, _, a, r), F_PatternMatching(_, a, r)) {
23 Message($"Test failed for n = {n}, a = {a}, r = {r}");
24 return false;
25 }
26 }
27
28 Message("Correct!");
29 true
30 }
31}
32