// Bernstein–Vazirani for the secret 0b1011, its oracle a subroutine over a // qubit register that reads the secret's bits on reading: every shot reads the // secret, r[i] its bit i. OPENQASM 3.1; include "stdgates.inc"; const uint[4] secret = 0b1011; def oracle(qubit[4] x, qubit y) { for uint i in [0:3] { if (((secret >> i) & 1) == 1) { cx x[i], y; } } } qubit[4] x; qubit y; bit[4] r; x y; h y; h x; oracle(x, y); h x; r = measure x;