Created
May 26, 2023 11:05
-
-
Save JesusCastroFernandez/731cce299ef2e94b62dab23afc94554d to your computer and use it in GitHub Desktop.
El código del algoritmo de Deutsch-Jozsa en Q#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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