Code for coursera 'Automata' class