A simple implementation of Turing Machine and its variations in Python.
It's a model of computation originally invented by Alan Turing, that operates on an infinite memory tape divided into discrete cells.
Each cell holds a single symbol from a finite set of symbols called the alphabet of the machine. It has a "head" that, at any point in the machine's operation, is positioned over one of these cells, and a "state" selected from a finite set of states. At each step of its operation, the head reads the symbol in its cell. Then, based on the symbol and the machine's own present state, the machine writes a symbol into the same cell, and moves the head one step to the left or the right, or stops the computation. The choice of which replacement symbol to write and which direction to move is based on a finite table that specifies what to do for each combination of the current state and the symbol that is read.
More: Turing Machine - Wikipedia.
Base class for each of machines.
A machine to compute the sequence 0 1 0 1 0 1... (0 1 0...). It never reaches the final state.
A machine that swaps all 0s and 1s.
Increments the input number by 1.
A machine that returns 1 if an input id s palindrome, or 0 otherwise.
Examples available in: examples.py and /tests.
pip3 install -r requirements.txt