Skip to main content
3 of 4
removed 1 byte
SevC_10
  • 469
  • 3
  • 8

Python 3, 138 bytes

Easy translation of the interpreter language instructions:

for i in[len(o)/11for o in input().split(' ')]:
 if i==1:a=0
 if i==2:a=a+1
 if i==3:a=a-1
 if i==4:a=a*2
 if i==5:a=a/2
 if i==6:print(a)

Try it online!

In the first line:

  1. takes the input
  2. split the instructions separated by a space
  3. divide by 11 (the lenght of the base word interpreter) to get the corresponding operation

The subsequent if execute the operations on the accumulator.

EDIT: theoretical improvements, code not modified (see version 2). Anyway, thanks for the suggestions!

-4 bytes thanks to @expressjs123

-3 bytes thanks to @ElPedro


VERSION 2

Python 3, 97 96 bytes

Improved the selection of the instructions simply by using list slicing.

-41 bytes compared to original version.

-1 byte thanks to @ElPedro

a=0
for i in[len(o)//11for o in input().split()]:
 a=[0,a+1,a-1,a*2,a/2,a][i-1]
 if i>5:print(a)

Try it online!

SevC_10
  • 469
  • 3
  • 8