EverybodyLang

From Esolang
Jump to navigation Jump to search

Add any command you want! (Don't forget updating the implementation!)

Commands

H   | Prints Hello world
Q   | Prints "Q"
9   | Prints 99 bottles of beer
+   | Increment
-   | Decrement
<   | Move left
>   | Move right
,   | Get user input(ASCII)
.   | Output(ASCII)
;   | Get user input as number
:   | Output as number
0   | Clear cell

Implementation

Assume code is the code.

def ninety_nine_bottles_of_beer():
	print("99 bottles of beer on the wall, 99 bottles of beer.\nTake one down, pass it around,", end = "")
	for i in range(99,0,-1):
		bottle = "bottles"
		if i == 1: bottle = "bottle"
		print("%d %s of beer on the wall.\n%d %s of beer on the wall, %d %s of beer." % ((i,bottle)*3))
		print("Take one down, pass it around, ", end = "")
	print("no bottles of beer on the wall.\nNo bottles of beer on the wall, no bottles of beer.")
	print("Go to store, buy some more, 99 bottles of beer on the wall!")

mem = {}
memc = 0
pc = 0
while pc < len(code):
	cur = code[pc]
	if cur == "H": print("Hello, world!")
	if cur == "Q": print("Q")
	if cur == "9": ninety_nine_bottles_of_beer()
	if cur == "+": mem[memc] += 1
	if cur == "-": mem[memc] -= 1
	if cur == "<": memc -= 1
	if cur == ">": memc += 1
	if cur == ";": mem[memc] = int(input())
	if cur == ":": print(mem[memc])
	if cur == ",": mem[memc] = ord(int(input()))
	if cur == ".": print(chr(mem[memc]))
	if cur == "0": mem[memc] = 0
	pc += 1