Library

Counter · One-counter

A valid expression in reverse Polish notation

n pushes an operand; o, a binary operator, takes two and leaves one. The counter is the depth of the evaluation stack: an operator needs at least two, and a valid expression ends with exactly one. A calculator’s stack, reduced to its height.

sneedlastdone
The machine as drawn — 4 states, 5 transitions.

The author’s examples, run

n → acceptnno → acceptnnono → acceptnnnoo → acceptnonn → rejectnn → rejecto → rejectnnooo → reject