turing_machine | A simple turing machine , written in Python | Machine Learning library
kandi X-RAY | turing_machine Summary
kandi X-RAY | turing_machine Summary
A simple Turing machine, written in Python. Check out for more details.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Processes the state
- Log the process after step
- Move the head
- Write character to the tape
- Read the next character from the tape
- Get the length of the mesh
- Get the tape
- Remove trailing sharps
- Subtract a word
- Adds a word
- Decrement a word
- Simulate a word
turing_machine Key Features
turing_machine Examples and Code Snippets
Community Discussions
Trending Discussions on turing_machine
QUESTION
A Turing machine manipulates symbols on an infinite strip of tape according to a table of rules.
In my case entries on the tape can be either 0's and 1's (binary).
The tape starts off 'empty' with an infinity of 0's in both positive and negative directions. This tape gets written on based on the rules that the machine follows, potentially adding 0's or 1's to the unwritten edges.
Since the tape values are binary is there a most efficient way to represent them in memory as the machine writes to the tape, adding new values to the left or right? Obviously I don't need to represent the infinite zeros (unwritten tape), but I do need to expand the data structure as new values are added to the ends of the tape.
A python list could do the trick, shown here inserting a 1 on the left:
...ANSWER
Answered 2017-Mar-30 at 07:36Given that the tape is infinite at both ends, you will have to consider the (-inf, -1]
range of indices too. The best representation, IMO, would be a pair of lists - one for the non-negative range and the other for the negative range (with indexing reversed). As you move beyond the allocated range of the tape, you will simply have to append to the respective list (which, unlike prepending to a list, is a fast operation).
A draft implementation (using an enhanced version of GrowingList
from this answer):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install turing_machine
You can use turing_machine like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page