Your code’s dry run, drawn on paper
Paste a Python solution and an input. Watch every step drawn.
nums array, 2 pointers
- total
- 14
- target
- 14
It draws what your code does
No special API and no annotations. DryRun watches what each variable is used for and draws it that way.
| When your code… | you see |
|---|---|
indexes a list with moving integers, nums[left] | the array, with each index variable as an arrow under its cell and the window between two pointers shaded |
| calls a function from inside itself | the recursion tree, the current path in red, memo hits marked apart from real calls, big subtrees folded |
fills dp[i][j] from other cells | the table filling in, the cell just written highlighted and the cells it read marked |
follows node.next | boxes and arrows, with slow, fast, prev and curr written on their nodes |
walks node.left and node.right | the tree, numbered in the order your code visits it |
| keeps neighbours in a dict or list | the graph, with the visited set shaded and the queue’s nodes outlined |
uses heapq, append and pop, or popleft | a heap as a tree and an array, a stack standing up, a queue lying down |
Every highlight is an event the tracer recorded. A comment like # dryrun: grid dp overrides the guess.
How it works
Python in your browser
Your code runs in Pyodide, CPython compiled to WebAssembly, inside a Web Worker, so the page never freezes. Nothing is sent to a server; there isn’t one.
A tracer that records, not guesses
sys.settrace records every line, call and return, with the variables that changed. Two names for one list stay one list.
Limits, said out loud
5,000 steps, 200 nested calls and a few seconds per run. When a run hits a limit, DryRun says which one, and at which line.
Pattern library
Twenty short programs, one per pattern, written for DryRun. Each opens with its input and runs.
- Pair with a target sumTwo pointers
- Shortest run reaching a totalSliding window
- First position not below a valueBinary search
- Range totals from a prefix arrayPrefix sums
- Days until a warmer readingMonotonic stack
- Fewest hops between two stationsQueue / BFS
- Count the islands on a mapDFS
- Pick k items from a listRecursion and backtracking
- Ways to climb with 1 or 2 stepsMemoized DP
- Paths through a grid with walls2D DP
- Longest common subsequence2D DP
- Reverse a linked listLinked list
- Middle node with fast and slow pointersLinked list
- In-order walk of a search treeTree traversal
- A tree, level by levelQueue / BFS
- The k largest scoresHeap
- Friend circles with union-findUnion-find
- Cheapest route on a small mapDijkstra
- Group words that are anagramsHash map
- Last player standingQueue