Oracles
Sealed Oracle Deutsch-Jozsa
Difficulty: Easy ★
A vendor ships you a sealed oracle gate and promises the function inside is either constant or balanced. One query is all you get, and the same circuit has to work no matter which oracle arrives.
Objective
build_deutsch_jozsa_circuit(oracle, num_inputs) receives a Gate acting on num_inputs + 1 qubits as |x>|y> -> |x>|y XOR f(x)> (inputs on qubits 0..n-1, output on qubit n). Return an (n + 1)-qubit circuit that leaves the input register in |0...0> if f is constant and never in |0...0> if f is balanced.
Constraints
- Append the oracle exactly once with qc.append(oracle, ...).
- Do not inspect the oracle: every non-oracle gate must be identical for every oracle.
Entry Point
build_deutsch_jozsa_circuitChecks
- Exports build_deutsch_jozsa_circuit(oracle, num_inputs).
- Distinguishes constant and balanced oracles on 1, 2 and 3 inputs.
- The circuit is identical apart from the oracle box.
Your Code
Outputpending
Execution results will appear here.