Conceptual illustration of paired paper arches around stacked blocks, with one unmatched arch aside.

Example result illustrating this prompt's visual direction. Actual results may vary by model, reference image and settings.

Balanced Parentheses Stack from Parsing Notes

Turn bracket-checking notes into push, match, pop and failure states.

Prompt

Transform the uploaded photo of handwritten algorithm notes into a clean, readable visual walkthrough. Treat the photo as the source of truth: preserve its algorithm, legible input values and stated conventions; remove glare, skew and paper clutter while retaining a small source-note inset. Do not invent unreadable values or silently repair contradictory logic; ask one focused question if an essential detail cannot be read. Use the optional example below only when the source has no worked example and label it "Illustrative example". Specify supported bracket types () [] {}. Read left to right; push opening brackets, and for a closing bracket require a nonempty stack with a matching top before popping. Accept only if no mismatch occurred and the stack is empty at the end. State how non-bracket characters are handled; default to ignoring them. Optional labeled success example: ([{}]); stack states after each character are (, ([, ([{, ([, (, empty. Include a separate failure inset for ([)] at the third character, where ) mismatches top [. State O(n) time and O(n) worst-case auxiliary space. Layout: Use a character strip above six vertical stack snapshots; make the top of stack explicit and isolate the mismatch inset from the successful trace. Use an off-white canvas, dark high-contrast sans-serif labels and spacious cells. Include the algorithm title, input, numbered steps, final result and the stated complexity note. Pair colors with labels or outlines so meaning does not depend on color alone. Keep all values and state changes consistent across panels. If space is tight, simplify decoration rather than omitting essential steps. Output one polished educational image; treat it as a visual explanation, not executable code. Before finalizing, check the trace and all visible labels against the source.
Recommended: ChatGPT
Upload your photo to the AI tool first, then use this prompt. The prompt asks the model to preserve identity and key visual features.

How to use it

  1. Upload a clear photo of the relevant handwritten algorithm notes.
  2. Paste this prompt and specify any required input or indexing convention.
  3. Check the rendered values and labels against your source before publishing.

Common failure fixes

  • If any closing bracket pops blindly, compare its type with the stack top first.
  • If a premature closing bracket is accepted, fail when the stack is empty.
  • If leftover openers are accepted, require an empty stack after the final character.