Comments on Write a Deadfish Interpreter
Parent
Write a Deadfish Interpreter
A rewrite of this SE question with a simpler input format and guidelines.
Challenge
Deadfish uses a single accumulator, on which all commands are to be performed.
It has the following commands:
Command | Description |
---|---|
i |
increment the accumulator |
d |
decrement the accumulator |
s |
square the value of the accumulator |
o |
output the value of the accumulator as a number |
If, after executing a command, the accumulator is equal to -1 or equal to 256, the accumulator must be reset to zero.
I/O
Input can be taken as a single string, list of codepoints, or any other reasonable format. It is guaranteed that the input will only consist of deadfish commands.
Output can be given as an array of numbers, or just the numbers printed with separators between them.
Testcases
(some are borrowed from the Esolangs wiki)
iissso -> 0
diissisdo -> 288
iissisdddddddddddddddddddddddddddddddddo -> 0
isssoisoisoisoiso -> 1,4,25,676,458329
ooooosioiiisooo -> 0,0,0,0,0,1,16,16,16
iiii -> nothing
iiiiiiiissdiiiiiiiiiiiiiiiiio -> 4112
o -> 0
Lua 5.4.4, 99 bytes ``` =0 …
2y ago
Vyxal `D`, 26 bytes ``` 0Ȯ …
3y ago
[APL (Dyalog Classic)], 47 byt …
4y ago
[JavaScript (Node.js)], 80 byt …
4y ago
C (gcc), 98 bytes ``` c =0 …
2y ago
[C (gcc)], 153 bytes …
4y ago
JavaScript (V8), 78 bytes ` …
2y ago
Ruby, 70 67 66 bytes ```rub …
3y ago
Post
Lua 5.4.4, 99 bytes
_=0s:gsub('.',function(c)_=({d=_-1,i=_+1;s=_*_})[c]or print(_)or _ _=({[256]=0,[-1]=0})[_]or _ end)
Thanks to @orthoplex for more shortening.
0 comment threads