\n",
"\n",
"\n",
"## Mainline Navigation\n",
"\n",
"Step 42 of 59. Follow the official walkthrough in order.\n",
"\n",
"Previous notebook: [Grover and Amplitude Amplification Problems](problems.ipynb)\n",
"\n",
"Next notebook: [Qiskit Patterns and Workflow Design Lecture](../../professional/module_01_qiskit_patterns/lecture.ipynb)\n",
"\n",
"Rule: complete the mandatory cells in this notebook before you open the next one.\n"
],
"id": "9f0d745e"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"The studio closes the algorithmic-design band by asking for a real search-design memo. This is where the earlier lecture and lab work should condense into a small piece of professional reasoning.\n"
],
"id": "12c18de6"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Design Brief\n",
"\n",
"\n",
" Build a two-qubit Grover design study that compares at least two targets and at least two iteration choices, then write a recommendation that defends the oracle style, diffuser reuse, and final iteration count.\n"
],
"id": "85dab059"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "setup"
},
"source": [
"\n",
"
\n",
"MANDATORY SETUP · Difficulty 1/10 · Environment, import, or helper cell required by the notebook.\n",
"
\n",
"\n",
"## Studio Prompt 1: Target Family\n",
"\n",
"\n",
" Show that the search routine works as a family over multiple marked states and that your target-marking code remains readable across those changes.\n"
],
"id": "23f85df4"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 3/10 · Official walkthrough runnable or written exercise.\n",
"
\n"
],
"id": "256f55de"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"editable_code = '\\nfrom qiskit import QuantumCircuit\\n\\ndef grover_oracle(target: str = \"11\") -> QuantumCircuit:\\n oracle = QuantumCircuit(2, name=f\"oracle_{target}\")\\n if target[0] == \"0\":\\n oracle.x(1)\\n if target[1] == \"0\":\\n oracle.x(0)\\n oracle.cz(0, 1)\\n if target[1] == \"0\":\\n oracle.x(0)\\n if target[0] == \"0\":\\n oracle.x(1)\\n return oracle\\n\\ndef diffuser() -> QuantumCircuit:\\n circuit = QuantumCircuit(2, name=\"diffuser\")\\n circuit.h([0, 1])\\n circuit.x([0, 1])\\n circuit.cz(0, 1)\\n circuit.x([0, 1])\\n circuit.h([0, 1])\\n return circuit\\n\\ncircuit = QuantumCircuit(2, 2)\\n# [1] Uniform search state\\ncircuit.h([0, 1])\\n# [2] Mark the target by phase\\ncircuit.compose(grover_oracle(\"11\"), inplace=True)\\n# [3] Reflect about the mean\\ncircuit.compose(diffuser(), inplace=True)\\n# [4] Report the amplified candidate\\ncircuit.measure([0, 1], [0, 1])\\n'\n",
"editable_circuit_lab(\n",
" initial_code=editable_code,\n",
" context={\"QuantumCircuit\": QuantumCircuit, \"simulate_counts\": simulate_counts},\n",
" title='Studio 1: Target Family',\n",
" instructions='Build a small family of target-marked searches and defend the readability of your oracle implementation.',\n",
" shots=256,\n",
")\n"
],
"id": "3364ad7b"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Studio Prompt 2: Iteration Memo\n",
"\n",
"\n",
" Compare one and two iterations as if you had to advise another engineer which to keep for this search size.\n"
],
"id": "216b1747"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 3/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"\n",
"## Studio Prompt 3: Oracle Review\n",
"\n",
"\n",
" Rewrite or refactor the oracle helper until you are satisfied that a reviewer could check it quickly without guessing which state is marked.\n"
],
"id": "760ccbad"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 3/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"MANDATORY TEST · Difficulty 3/10 · Official walkthrough multiple-choice test.\n",
"
\n"
],
"id": "81b9a6e6"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'What is a strong studio deliverable for Grover?', 'options': ['A notebook comparing target choices and iteration counts with a written design recommendation', 'A single run of the textbook circuit', 'A list of gate names with no explanation'], 'correct_index': 0, 'explanation': 'The studio should convert the routine into a defended design decision.'}, {'prompt': 'Why is a tiny search space pedagogically useful here?', 'options': ['Because the mechanism and the over-rotation risk are both easy to see locally', 'Because Grover works only on two qubits', 'Because the oracle no longer matters'], 'correct_index': 0, 'explanation': 'Small systems make the geometry visible.'}], heading='Studio Design Check')\n"
],
"id": "c33ae767"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Studio Debrief\n",
"\n",
"\n",
" A successful studio notebook here reads like a design note rather than like a performance. It should be compact, explicit, and willing to defend why one candidate was chosen over another. That is the right note on which to leave the algorithmic-design band.\n"
],
"id": "086de0fb"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## Studio Standard\n",
"\n",
"A strong studio notebook is compact, explicit, and reviewable. It does not hide behind volume. It makes clear what family of circuits was explored, what invariant mechanism survived across the variants, what evidence justified the final recommendation, and what tradeoffs remained open. If your notebook cannot answer those questions yet, keep refining it. That refinement is the studio.\n"
],
"id": "c57f0a8b"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"
\n",
"\n",
"## What A Finished Studio Should Feel Like\n",
"\n",
"The finished notebook should feel like a small engineering artifact rather than a scrapbook. A reviewer should be able to open it, understand the task, inspect the candidate circuits, see the evidence, and understand why one recommendation won. If that standard is met on these small modules, later capstone work becomes much more realistic.\n"
],
"id": "df448163"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 3/10 · Official walkthrough runnable or written exercise.\n",
"
\n"
],
"id": "c5a957cd"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"reflection_box('Which target family did you compare, and what did that reveal about your oracle helper?')\n"
],
"id": "a3fb6757"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "mandatory",
"ql_role": "exercise"
},
"source": [
"\n",
"
\n",
"MANDATORY EXERCISE · Difficulty 3/10 · Official walkthrough runnable or written exercise.\n",
"
\n",
"\n",
"\n",
"## What To Open Next\n",
"\n",
"Next notebook: [Qiskit Patterns and Workflow Design Lecture](../../professional/module_01_qiskit_patterns/lecture.ipynb)\n",
"\n",
"Official walkthrough rule: once every mandatory cell above is complete, open the next notebook. Anything below this cell is facultative.\n"
],
"id": "5eea683b"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "facultative_zone",
"ql_track": "meta",
"ql_role": "reading",
"ql_difficulty": 1,
"ql_note": "Optional-zone boundary. The official walkthrough is already complete above."
},
"source": [
"\n",
"
\n",
"META READING · Difficulty 1/10 · Optional-zone boundary. The official walkthrough is already complete above.\n",
"
\n",
"\n",
"\n",
"## Facultative Extension Zone\n",
"\n",
"You have already completed the mandatory walkthrough for **Grover and Amplitude Amplification Studio**. Everything below is optional. Use it only if you want deeper consolidation or extra transfer work.\n"
],
"id": "fef497ee"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "facultative",
"ql_track": "facultative",
"ql_role": "reading",
"ql_difficulty": 5,
"ql_note": "Optional extension reading."
},
"source": [
"\n",
"
\n",
"\n",
"## Facultative Extension Reading\n",
"\n",
"Use this optional studio extension only if the mandatory route in **Grover and Amplitude Amplification Studio** feels stable. The right stretch here is not random complexity; it is one extra candidate, one sharper criterion, and one clearer written defence of the final decision.\n"
],
"id": "fdbeb292"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "facultative",
"ql_role": "test"
},
"source": [
"\n",
"
\n"
],
"id": "00503cf5"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"ql_injected": "facultative",
"ql_track": "facultative",
"ql_role": "test",
"ql_difficulty": 6,
"ql_note": "Optional multiple-choice extension.",
"jupyter": {
"source_hidden": true
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"quiz_block([{'prompt': 'What makes a facultative studio stretch worthwhile?', 'options': ['It sharpens a design judgement without breaking the single mandatory route', 'It replaces the mandatory brief', 'It adds complexity with no explicit criterion'], 'correct_index': 0, 'explanation': 'A studio stretch should sharpen judgement, not blur the route.'}, {'prompt': 'If a stretch candidate fails, what should change first?', 'options': ['The written explanation of the failure and the next criterion', 'The notebook order', 'The insistence that the failed candidate was still best'], 'correct_index': 0, 'explanation': 'The useful move is clearer review language and a better criterion.'}], heading='Facultative Extension Test')\n"
],
"id": "ff99b292"
},
{
"cell_type": "markdown",
"metadata": {
"ql_injected": "badge",
"ql_track": "facultative",
"ql_role": "exercise"
},
"source": [
"\n",
"