Given any natural number
k such that
k<256, produce an deadfish program that gives the smallest solution possible.
Deadfish is a joke esoteric programming language. It has a single unsigned byte of memory, called the
accumulator, initialized at 0. There are four commands which form a string.
accumulator += 1
accumulator -= 1
accumulator = accumulator * accumulator
For example, the string
iiisis would produce 100, as this would be the memory after each command:
- i -> 1
- i -> 2
- i -> 3
- s -> 9
- i -> 10
- s -> 100
- Read a number through any reasonable means (from a file, STDIO, or a function argument), and output an optimal string of commands producing that number.
- A solution is considered optimal if there are no solutions that use fewer commands.
- Output through any reasonable means (to a file, STDIO, or a return value).
- The accumulator may not exceed 256.
0 -> (Empty string, nothing, or error) 1 -> i 4 -> iis 8 -> iiisd 35 -> iisiisd 150 -> iiisiiisiiiiii 256 -> (Empty string, nothing, or error)