Python Turing Machine basic implementation