microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
amcasey/ArrayWrap

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/marking_oracles/contains_substring/Verification.qs

32lines · modecode

1namespace Kata.Verification {
2 import KatasUtils.*;
3
4 function F_ContainsSubstring(args : Bool[], r : Bool[]) : Bool {
5 let N = Length(args);
6 let K = Length(r);
7 for P in 0..N - K {
8 if F_ContainsSubstringAtPosition(args, r, P) {
9 return true;
10 }
11 }
12 return false;
13 }
14
15 @EntryPoint()
16 operation CheckSolution() : Bool {
17 for (n, r) in [
18 (2, [true]),
19 (3, [false, true]),
20 (4, [true, true, false]),
21 (5, [false, false])
22 ] {
23 if not CheckOracleImplementsFunction(n, Kata.Oracle_ContainsSubstring(_, _, r), F_ContainsSubstring(_, r)) {
24 Message($"Test failed for n = {n}, r = {r}");
25 return false;
26 }
27 }
28
29 Message("Correct!");
30 true
31 }
32}