A simple implementation of a Turing machine solution to the balanced parentheses problem.
There's really nothing special to see here. In CSE 355 (Theoretical Computer Science) at ASU we had a problem where we drew a TM to accept strings containing balanced parentheses. I felt like translating it to actual code.
- unlike the basic TM from class, this one can work with any strings (as in, it may consist of more than just parentheses)
- it handles brackets, curly braces, and angle braces, too
- it does some stupid ascii trickery to cut down on code slightly, because all of the characters except parentheses happen to be 2 values away from each other like this:
- it expects user input on loop, you must type "done" to finish
()
(){}
(hello_world())[5];
This string has no parentheses, curly braces, or brackets.
<haha <(owo)> funny face> [({ })]
(
]
}{
[({])}
<(uwu<) this won't work
done