Deadfish is a joke "programming language" with four commands. Because the Esolang page is a bit contradictory and the interpreters on that page don't all work exactly the same, you should implement the following variation:
- There is an accumulator which is at least 16 bits in size, more is allowed but less is not. Negative numbers do not need to be supported. The accumulator is
0when the program starts.
- There are the following two sets of four commands, and your program must support both at the same time.
Standard Deadfish │ XKCD Variant │ Meaning ─────────────────────┼──────────────────┼──────────────────────────────────── i │ x │ Increment accumulator d │ d │ Decrement accumulator s │ k │ Square ( acc = acc * acc ) o │ c │ Output accumulator, as a number
- If, after executing a command, the accumulator is either
256, the accumulator must be reset to zero. Note that this is not normal wrap-around. If, say, the accumulator is
20, and the
scommand is run, the accumulator should be
400afterward. Similarly, if the accumulator is
dcommand is run, the accumulator should become
- Any input that isn't one of these commands should be ignored.
Your program should display a prompt:
>>. The prompt must be at the beginning of a new line. It should then read a line of user input, and run the given commands left-to-right. When outputing numbers, the numbers must be separated. I.e.,
12 34 is OK,
12,34 is OK,
is OK, but
1234 is not.
Your program should keep doing this in a loop, at least until
EOF is reached.
>> xiskso 0 >> xiskisc 289 >> ddddo ddddo 285 281 >> ddddo ddddo 277 273 >> dddddddo 266 >> dddddddddo 257 >> do 0 >> do 0 >> io 1 >>