Interpret deadfish


Please participate in the meta discussion about reopening this challenge before casting a vote.


This challenge was inspired by .

Deadfish is a non-Turing-complete programming language, created by Jonathan Todd Skinner. It has an accumulator register and contains 4 commands, i, d, s, and o, standing for increment, decrement, square, and output, respectively. While this seems simple enough, the original implementation has some quirks that must be present in your interpreter.

Unlike a similar challenge here, this does not require the interpreter to be interactive.


The challenge is to write a fully functional Deadfish interpreter, quirks included. The following requirements must be met:

  • The accumulator must be more than 8 bits wide.
  • When an i is encountered, increment the accumulator by 1.
  • When a d is encountered, decrement the accumulator by 1.
  • When an s is encountered, square the value of the accumulator.
  • When an o is encountered, print the value of the accumulator along with a newline.
  • When any other character is encountered, including control characters and whitespace but not a newline, print a newline.
  • If and only if the accumulator equals -1 or 256, set the accumulator to 0.

Test cases

From the esolangs article:

iissso -> 0
diissisdo -> 288
iissisdddddddddddddddddddddddddddddddddo -> 0


  • Input may be accepted through STDIN or as argument(s).
  • Standard loopholes are disallowed
  • This is , so the shortest solution in bytes wins


Posted 2018-02-15T17:21:46.190

Reputation: 427

Question was closed 2018-02-16T14:42:55.420

@dylnan This one doesn't impose an interactivity requirement, however, allowing more languages to be used – robbie – 2018-02-15T17:26:38.330

True. I think people will say you should make a meta post about it. If they say it's a good idea and you link to the meta post on this post then people will be okay with it.

– dylnan – 2018-02-15T17:30:56.777

@Uriel yes it should! – robbie – 2018-02-15T17:40:03.537

Related meta post. – Mr. Xcoder – 2018-02-15T19:32:41.580



Proton, 114 bytes

a=0s={"i":(a=>a+1),"d":(a=>a-1),"s":(a=>a*a),"o":(a=>[print(a),a][1])}for i:input(){a=s[i](a)if a in[-1,256]{a=0}}

Try it online!

The fact that this even parses correctly demonstrates how weird Proton 1 is o_O


Posted 2018-02-15T17:21:46.190

Reputation: 26 575