Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#Example program
prog = [ 21, -1, -2, #0 #Print loc 21
19, 20, -1, #3 #Subtract 1 from pos 20, quit when 0
18, 0, -2, #6 #Add one to pos 0
17, 17, 0, #9 #Jump to pos 0
0, 0, 0, #12
0, 0, 0, #15
-1, 1, 13, #18 Pos 20 is string length
72, 101, 108, #21 #Data begins here
108, 111, 32,
87, 111, 114,
108, 100, 33,
10]
pc=0
c=0
out=""
while True:
c+=1
a,b,c=prog[pc:pc+3]
if c==-2:
c=pc+3
pc+=3
if b>=0:
prog[b]-=prog[a]
result=prog[b]
else:
result=-1
if b==-1:
out+= chr(prog[a])
if result<=0:
pc=c
if pc<0:
break
print(out)