Library

DFA · Regular

An even number of 0s, or exactly two 1s

A union, built as a product: one component counts 0s mod 2, the other counts 1s up to three. Accept when either component is happy — eight states, laid out as the 2 × 4 grid they are.

e0o0e1o1e2o2e3o30101010101010101
The machine as drawn — 8 states, 16 transitions.Every word up to length 8, one row per length in shortlex order, inked where it is accepted.

The author’s examples, run

ε → accept00110 → accept1 → accept0000000110 → accept0 → reject0010 → reject01 → reject1000000110 → reject