Skip to content

Instantly share code, notes, and snippets.

@frankzickert
Created June 23, 2022 12:27
Show Gist options
  • Save frankzickert/87a25b41ac2d44973852840e6952aec5 to your computer and use it in GitHub Desktop.
Save frankzickert/87a25b41ac2d44973852840e6952aec5 to your computer and use it in GitHub Desktop.
def oracle(secret, as_gate=True):
o_qc = QuantumCircuit(DIGITS+1)
for i in range(DIGITS):
if secret[::-1][i] == '1':
o_qc.cx(i,DIGITS)
else:
o_qc.i(i)
return o_qc.to_gate(label="oracle") if as_gate else o_qc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment