Calculate the result of a turing machine on a given tape
Project description
Table of Contents
Introduction
Run any Turing machine possible using this function and see if the turing machine, accepts or rejects the tape yu 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 = create_turing_machine(tape, states, transition_rules)
print("Result:", result)
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
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for turing_machine_utils-1.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c20b524b85d8d27422d399e679db3f2a1929cf20c9c83250e7daf3c3e42ab34a |
|
MD5 | 94e084ac1ad65552d72f04f2e8d6cf34 |
|
BLAKE2b-256 | 16a2b5bd03d7a4e2b0fdeb38d15144f643939569e87851237312af64ad404424 |
Close
Hashes for turing_machine_utils-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ddf7e237ac74d07cc174520e3a0469cf6e3e7177500b3b8a5929f7c2edeee6e |
|
MD5 | 4e3b700855973f6b2fbf7e95421ace3e |
|
BLAKE2b-256 | d1333785cdd4dc29dd2c154fa7dc0c51d85f9ebe58a72a55a983ea5552261970 |