OZZo

From Esolang
Jump to navigation Jump to search

Created by User:Fly, oZZo (that stands for "one zero zero one" or "1001") is an esoteric programming language that uses instructions made of binary numbers.

Instructions

Command Description
1111 sets memory to true
0000 sets memory to false
1001 print memory
1110 input
1010 save input in memory
1101 clear memory
0101 sets errorlevel to 1
1011 sets errorlevel to 0 (by default is zero)
0100 checks if errorlevel is 1 than goes to the next instruction
0110 checks if errorlevel is 0 than goes to the next instruction
0111 break

Exemple programs

Hello World

111010101001

Input: !dlroW ,olleH (yes it has to be backwards since binary numbers are read backwards, the input will be backwards too)

Output: Hello, World!

Computational Class

I have to say that this language is not turing complete, since the language memory is based on only one variable in the intepreter, and even if the memory was infinite or based on an array it still wouldn't be turing complete.

Implementation

import textwrap

memory = ""
inp = ""
errorlevel = 0

code = input()

# 1111 = sets memory to true
# 0000 = sets memory to false
# 1001 = print memory
# 1110 = input
# 1010 = save input in memory
# 1101 = clear memory
# 0101 = set errorlevel to 1
# 1011 = set errorlevel to 0
# 0100 = check if errorlevel is 1 than go to the next instruction
# 0110 = check if errorlevel is 0 than go to the next instruction
# 0111 = stops the program

instructions = textwrap.wrap(code,4)

for part in instructions:
	if part == "1110":
		inp = input()
	elif part == "1010":
		memory = inp
	elif part == "1001":
		print(memory[::-1])
	elif part == "1101":
		memory = ""
	elif part == "0101":
		errorlevel = 1
	elif part == "1011":
		errorlevel = 0
	elif part == "0111":
		break
	elif part == "0100":
		if errorlevel == 1:
			if instructions[instructions.index(part)+1] == "1110":
				inp = input()
			if instructions[instructions.index(part)+1] == "1010":
				memory = inp
			if instructions[instructions.index(part)+1] == "1001":
				print(memory[::-1])
			if instructions[instructions.index(part)+1] == "1101":
				memory = ""
			if instructions[instructions.index(part)+1] == "0111":
				break
			if instructions[instructions.index(part)+1] == "1111":
				memory = "eurt"
			if instructions[instructions.index(part)+1] == "0000":
				memory = "eslaf"
	elif part == "0110":
		if errorlevel == 0:
			if instructions[instructions.index(part)+1] == "1110":
				inp = input()
			if instructions[instructions.index(part)+1] == "1010":
				memory = inp
			if instructions[instructions.index(part)+1] == "1001":
				print(memory[::-1])
			if instructions[instructions.index(part)+1] == "1101":
				memory = ""
			if instructions[instructions.index(part)+1] == "0111":
				break
			if instructions[instructions.index(part)+1] == "1111":
				memory = "eurt"
			if instructions[instructions.index(part)+1] == "0000":
				memory = "eslaf"
	elif part == "1111":
		memory = "eurt"
	elif part == "0000":
		memory = "eslaf"