4
Please participate in the meta discussion about reopening this challenge before casting a vote.
Introduction
This challenge was inspired by semicolon-#.
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.
Challenge
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
or256
, set the accumulator to0
.
Test cases
From the esolangs article:
iissso -> 0
diissisdo -> 288
iissisdddddddddddddddddddddddddddddddddo -> 0
Rules
- Input may be accepted through STDIN or as argument(s).
- Standard loopholes are disallowed
- This is code-golf, so the shortest solution in bytes wins
@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