Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JesusCastroFernandez/731cce299ef2e94b62dab23afc94554d to your computer and use it in GitHub Desktop.
Save JesusCastroFernandez/731cce299ef2e94b62dab23afc94554d to your computer and use it in GitHub Desktop.
El código del algoritmo de Deutsch-Jozsa en Q#
open Microsoft.Quantum.Diagnostics;
operation DeutschJozsaAlgorithm (f : ((Qubit[], Qubit) => Unit is Adj)) : Bool {
using (register = Qubit[2]) {
// Prepare the initial state.
H(register[0]);
X(register[1]);
H(register[1]);
// Apply the oracle.
f(register, One);
// Measure the result.
let result = MultiM(register);
// Return true if the function is constant.
return result == [false, false];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment