MIX
From Esolang
Contents |
[edit] MIX
MIX is an esoteric language invented by User:Feuermonster in April 2008. MIX has one integer (called buffer) to store data. I couldn't write a hello world program till now. But it should be possible.
[edit] Instructions
- 0 Prints out the buffer as a character
- 1 Adds 1 to the buffer
- 2 Subtracts 1 from the buffer
- 3 Adds 60 to the buffer
- 4 Sets the buffer to zero
- 5 Buffer %= 256
- 6 Adds the buffer to the counter
- 7 Subtracts the buffer from the counter
- 8 Adds the buffer to the index
- 9 Subtracts the buffer from the index
[edit] What's MIX
MIX mixes the array, actually it just shifts.
for example:
(Code = 08151234)
Code: 08151234
[8, 0, 4, 9]
Executed as follow: 4.
(Code = 314159314159)
[2, 0, 8, 6] 1 [8, 6, 4, 8] 4 [7, 3, 7, 3] 1 [7, 3, 3, 3] 5 [8, 4, 3, 4] 9
Executed as follow: 1 4 1 5 9
[edit] Interpreter
def main():
op = ['','','','']
code_ = raw_input("Code: ")
index = 3
i=0
code=[]
buffer=65
output=''
for chr_ in code_:
code.append(int(chr_))
while (i < len(code)):
op[(i+(index == i)) % len(op)] = code[i]
to_ip = op[index % len(op)]
if(to_ip==''):
i+=1
continue
to_ip = int(to_ip)
if(to_ip==0):
output += str(chr(buffer))
if(to_ip==1):
buffer+=1
if(to_ip==2):
buffer-=1
if(to_ip==3):
buffer+=60
if(to_ip==4):
buffer=0
if(to_ip==5):
buffer = buffer % 256
if(to_ip==6):
i += buffer
if(to_ip==7):
i -= buffer
if(to_ip==8):
index += buffer
if(to_ip==9):
index -= buffer
temp = op[0]
op[i % 4] = (op[(i+1)%4] + i) % 10
op[(i + 1) % 4] = (op[(i+2)%4] + i) % 10
op[(i + 2) % 4] = (op[(i+3)%4] + i) % 10
op[(i + 3) % 4] = (temp + index) % 10
op[0],op[3] = op[3],op[0]
#print op
#print to_ip
index+=1
i+=1
print output
main()
raw_input()

