Oracles

Mark the String

Difficulty: Easy ★

Every Grover search needs a phase oracle. Build one that flips the sign of exactly one bitstring, so it works as a drop-in oracle.

Objective

build_phase_oracle(marked) receives a bitstring (rightmost character = qubit 0) and returns a len(marked)-qubit circuit with unitary I - 2|marked><marked| (up to global phase).

Constraints

  • No unitary / diagonal / initialize shortcuts.

Entry Point

build_phase_oracle

Checks

  • Exports build_phase_oracle(marked).
  • Flips only the marked state for 1- to 5-qubit strings.

Your Code

Outputpending

Execution results will appear here.