microsoft/qdk

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dmitryv/select-updated

Branches

Tags

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

Clone

HTTPS

Download ZIP

katas/content/oracles/bit_pattern_challenge/solution.qs

18lines · modecode

1namespace Kata {
2 open Microsoft.Quantum.Arrays;
3
4 operation ArbitraryBitPattern_Oracle_Challenge(
5 x : Qubit[],
6 pattern : Bool[])
7 : Unit is Adj + Ctl {
8 within {
9 for i in IndexRange(x) {
10 if not pattern[i] {
11 X(x[i]);
12 }
13 }
14 } apply {
15 Controlled Z(Most(x), Tail(x));
16 }
17 }
18}
19