
Well, let's go through one way to do it together.

I find it helpful to draw the finite state machine first.

So here's my start state. We'll call it 1.

And because "q * " accepts the empty string, it also has to be an accepting state,

but I can see any number of q's that I like and still accept,

so it looks like we've got 1 state, 1 edge, and our state is also an accepting state.

So just to show that this program really works, we're going to run it in the interpreter.

Over here, I have defined edges, just as we suggested.

In state 1 on a 'q', you loop back to state 1.

State 1 is our start state, and it's also our accepting state.

Let's try out our simulation on a bunch of q's, the empty string, and a bunch of q's

with an evil interloper.

We've got this 'A' hiding here. This should be true. True. False.

Oh, and it is.

So our finite state machine simulator matches our intuition exactly.