microsoft/qdk
Publicmirrored fromhttps://github.com/microsoft/qdkAvailable
katas/content/marking_oracles/balanced/Verification.qs
21lines · modecode
| 1 | namespace Kata.Verification { |
| 2 | open Microsoft.Quantum.Katas; |
| 3 | open Microsoft.Quantum.Arrays; |
| 4 | |
| 5 | function F_Balanced(args : Bool[]) : Bool { |
| 6 | return Count(x -> x, args) == Length(args) / 2; |
| 7 | } |
| 8 | |
| 9 | @EntryPoint() |
| 10 | operation CheckSolution() : Bool { |
| 11 | for n in 2 .. 2 .. 6 { |
| 12 | if not CheckOracleImplementsFunction(n, Kata.Oracle_Balanced, F_Balanced) { |
| 13 | Message($"Test failed for n = {n}"); |
| 14 | return false; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | Message("Correct!"); |
| 19 | true |
| 20 | } |
| 21 | } |