stepwise
Back to demos

Demo - Automaton (experimental)

Watch an automaton read a word

This automaton decides whether a binary number is divisible by 3. Its state is the remainder so far: reading a bit doubles the number and adds the bit. It is declared once with fromGraph, then both run and drawn. Type a word and the walk grows as you type; edit it and the playhead stays at the same position. Below, you play the automaton yourself: each answer is a choice, a wrong one takes a detour, and changing an earlier answer cuts off the old future.

= 9 in decimalreading…
010101r0r1r2
1001

start: r0

read nothing = 0, remainder 0

1/5

Now you be the automaton

Same word. At each bit, pick the state the automaton moves to. Scrub back to an earlier question and pick differently: everything after it is replayed from your new answer. The link in the address bar holds the word and your answers, so it replays this exact walk.

r0Start in r0: nothing read, remainder 0
0 answered · 0 detours
Playing up to the next question…
1/2
apps/demo/app/automaton/demo.tsx - 309 lines GitHub Open in StackBlitz