microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
katas/content/marking_oracles/parity/Verification.qs
25lines · modecode
| 1 | namespace Kata.Verification { |
| 2 | import KatasUtils.*; |
| 3 | |
| 4 | function F_Parity(x : Bool[]) : Bool { |
| 5 | mutable parity = false; |
| 6 | for xi in x { |
| 7 | if xi { |
| 8 | set parity = not parity; |
| 9 | } |
| 10 | } |
| 11 | parity |
| 12 | } |
| 13 | |
| 14 | @EntryPoint() |
| 15 | operation CheckSolution() : Bool { |
| 16 | for n in 1..5 { |
| 17 | if not CheckOracleImplementsFunction(n, Kata.Oracle_Parity, F_Parity) { |
| 18 | return false; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | Message("Correct!"); |
| 23 | true |
| 24 | } |
| 25 | } |