Here's a chatgpt created turing complete language in python.
class Interpreter:
def __init__(self):
self.vars = {}
self.code = ''
self.pointer = 0
def run(self, program):
self.code = program
while self.pointer < len(self.code):
current_char = self.code[self.pointer]
if current_char == '>':
self.pointer += 1
elif current_char == '<':
self.pointer -= 1
elif current_char == '+':
self.vars[self.pointer] = self.vars.get(self.pointer, 0) + 1
elif current_char == '-':
self.vars[self.pointer] = self.vars.get(self.pointer, 0) - 1
elif current_char == '.':
print(chr(self.vars.get(self.pointer, 0)), end='')
elif current_char == ',':
self.vars[self.pointer] = ord(input()[0])
elif current_char == '[':
if self.vars.get(self.pointer, 0) == 0:
loop_count = 1
while loop_count > 0:
self.pointer += 1
if self.code[self.pointer] == '[':
loop_count += 1
elif self.code[self.pointer] == ']':
loop_count -= 1
elif current_char == ']':
loop_count = 1
while loop_count > 0:
self.pointer -= 1
if self.code[self.pointer] == '[':
loop_count -= 1
elif self.code[self.pointer] == ']':
loop_count += 1
self.pointer -= 1
self.pointer += 1
And the spec:
>: moves the pointer one position to the right
<: moves the pointer one position to the left
+: increments the value at the current pointer position on the tape
-: decrements the value at the current pointer position on the tape
.: prints the character represented by the value at the current pointer position on the tape
,: reads a character from the user and stores its ASCII value at the current pointer position on the tape
[: begins a loop. If the value at the current pointer position on the tape is zero, the interpreter jumps to the matching ] character.
]: ends a loop. If the value at the current pointer position on the tape is nonzero, the interpreter jumps back to the matching [ character.
This is a pretty standard programming problem for undergrads. First glance and it looks legitimate enough.