Table of Contents
Introduction
Run any Turing machine possible using this function and see if the turing machine, accepts or rejects the tape you input to it.
Installation
pip install turing-machine-utils
Usage
from turing_machine_utils import create_turing_machine
# Define Turing Machine states, alphabet, and transition rules
states = ['q0', 'q1', 'accept', 'discard']
transition_rules = {
('q0', '0'): ('q1', '1', 'R'),
('q0', '1'): ('q0', '0', 'R'),
('q1', '0'): ('accept', '0', 'L'),
('q1', '1'): ('discard', '1', 'L'),
}
# Define the input tape
tape = ['0', '1', '0', '1', '0']
# Run the Turing Machine
result, new_tape, state, symbol = create_turing_machine(tape, states, transition_rules)
print("Result:", result)
remember that the machine will start calculating the response from the first state. So the first element on the states list must be the beginning state
The result will be:
- 1 if the tape is accepted by the turing machine
- -1 if the state is discarded by the turing machine
- 0 if an undefined transition is found by the turing machine
The new_tape is the tape with the changes to the original tape
The state and symbol are normally None. They get values that say when the turing machine reached an undefined point
Configuration
No specific configuration options are available at the moment.
Contributing
Feel free to contribute by reporting issues, suggesting improvements, or submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for turing-machine-utils 1.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| turing_machine_utils-1.0.7.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| turing_machine_utils-1.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / turing_machine_utils-1.0.7.tar.gz
| Download URL | turing_machine_utils-1.0.7.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db56a2bd52ecd12b6156ffa5917f5894921ea2e3294ddfe13a4d0bbd51277e41
|
|
BLAKE2b-256 checksum How to use checksums |
88db4921fac79015832ee56dc1a96b52174d5cf5c4ef4d17d67e67f63ec009fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|
Release files / turing_machine_utils-1.0.7-py3-none-any.whl
| Download URL | turing_machine_utils-1.0.7-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba73277a4ec836f4d3c7b777547bd7da721445c43ae257afa72c99f0094c217d
|
|
BLAKE2b-256 checksum How to use checksums |
91c009545625b7e0302eb515fb622a24687ddf9cd20c1ffd3e79c72bb7cf862e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.18
|