Source: https://web.stanford.edu/class/cs103a/assn/070S Solutions for Practice with Automata.pdf