Fluff
After taking a look at deadfish, I decided it sucked, so I came up with a new (and easier) variant of it: imnotdeadfish.
As with its predecessor, there are 4 commands and an accumulator which begins at 0:
+ # increment the accumulator
- # decrement the accumulator
s # square the accumulator
o # output the accumulator as an ascii char
The only difference between the languages (besides using + and -) is that if the accumulator ever goes out of range of 0 <= x < 256, the accumulator is taken mod 256. Ex: if the accumulator is at 255
and the command + is executed, it wraps to 0, and if, for example, it is at 0
and the command is -, the result would be 255.
An example program such as this: ++++s+so
which would output !
Challenge
The problem with imnotdeadfish is that it's too easy, which means optimal solutions are not hard to find.
Given a string of characters, output the shortest code (which is not necessarily unique) in imnotdeadfish that prints the output. This should work for all inputs with chars between 0-255, but the testcases won't cover that.
Examples
input => output
Hello, World! => +++s+s-s-o++s+o+++++++oo+++o----ss++s+++os+s-o+++++s--o-s+++s--o+++o------o-s---sos+so
test => ++s+ss+++o++s+o++s++o+o
aaaaaaaaaa => +++s--ssoooooooooo
This is code-golf so the shortest program, in bytes, wins. (this is the program you write, not the resulting imnotdeadfish program, since those should be the same length)
Here is a reference implementation of imnotdeadfish (for testing - this is not a valid submission to this challenge).
--ss+so
is a shorter one for!
, found by my program :p \$\endgroup\$