Best afterFiltering a list·A comparison is a yes/no value

Collecting rainwater

Read a list of heights as a skyline of columns. After rain, water pools in the dips between taller columns. The trick: each column holds water only up to the LOWER of the tallest walls on its two sides — not the tallest wall anywhere.

Heights are columns. How many cells of water are trapped between them after rain?

Collecting rainwater — filled to the global peak execution-derived · CPython
same data, two zoom levels
state after line 1 runs
3
0
2
0
4
step 1 / 21

Click a line, drag the slider, or use the keys.

What you are looking at

Toggle to the abstraction and watch the blue water fill each column: the grey bars are the heights, and total counts the trapped cells.

This is a milestone — it puts several earlier ideas together into one small program.

Every state you see came from running the program under CPython's tracer at build time — see how GlassBox stays honest.