Solution (source code)

= Solution

A DFA consists of finite $Q$, alphabet $\Sigma$, transition $\delta$, initial $q_0$, and accepting set $F$. Extend by $\hat\delta(q,\epsilon)=q$ and $\hat\delta(q,wa)=\delta(\hat\delta(q,w),a)$. It accepts $\{w:\hat\delta(q_0,w)\in F\}$; a language is regular if some DFA accepts it.