text:
Short Deadfish Numbers
Deadfish is one of the best known non Turing-complete programming languages. It has only one accumulator (which starts at 0) to store data, and only four commands:
i - Increment the accumulator
s - Square the accumulator
d - Decrement the accumulator
o - Output the accumulator

A Deadfish program may look like:
iiisdo

And that would print:
8

The challenge
Create a program that will input a number and output Deadfish code to display the number.(Or make a function that takes the number as a parameter and returns the code.) It must work for any integer from 0 to 255
Goal
Try to make your code make the shortest code possible to generate the given number. For example:
iiiiiiiiio

and
iiiso

each print 9, but the second is shorter.
Scoring
Your score is:
The number of characters in your source code +
The sum of the lengths of your output for all numbers from 1-255
-100 if the language you chose is Deadfish :)

Lowest score wins!

In the original challenge I only had the sum of 6 numbers(9,17,99,100 and 123).
This was from me wanting to not make everyone test for every number, and I wanted the shortest code to be relevant. Then I realized that programmers are good at making scripts to test things like that, and I would rather have this be a contest for best algorithm with golfing as a tiebreaker.
Therefor I changed this, as suggested by Martin Büttner.

How is doing this in Deadfish possible if it takes no input?

@Calvin'sHobbies I don't think anyones getting that -100:)

Related

Does deadfish handle integers larger than 255? E.g. can we calculate 256 and subtract one? How is overflow handled? Is 16^2 = 0 or 16^2 = 256 or 16^2 = error?

@soktinpk If you hit -1 OR 256, then it gets reset to 0. But if you hit a number bigger than 256 by squaring then it's unchanged, e.g. 17^2 = 289. (see the esolang page)

@Sp3000 Yeah, that is how it works. We should maybe change the rules to specify the exact function of the commands.

@MegaTom just noticed now I have the best answer. so late... lol

Perl, 132 131 bytes + 2036 bytes = 2167
Includes +2 for -lp
Run with the target number on STDIN, e.g.
perl -lp deadfish.pl <<< 160

deadfish.pl:
@;=map{s%(o)|(s)|(i|d)|%$_-=e cmp$3.e;$_*=$_-16&&$_ if$2;$1&&$_%eg;@$_=$`;grep/id|di/^y/o//<4,<{o,s,d,i}$`>}~~o,@;until$\="@$_"}{

The grep is a filter to constrain the exponential explosion a bit (though this program still needs 2 GB for the hard cases). It also works without but I can't run it on my hardware like that except for the easy cases. But in principle this 110=108+2 byte program works too:
@;=map{s%(o)|(s)|(i|d)|%$_-=e cmp$3.e;$_*=$_-16&&$_ if$2;$1&&$_%eg;@$_=$`;<{o,s,d,i}$`>}$a,@;until$\="@$_"}{

Output list:
1   io
2   iio
3   iiio
4   iiso
5   iisio
6   iisiio
7   iisiiio
8   iiisdo
9   iiiso
10  iodo
11  ioo
12  ioio
13  ioiio
14  ioiso
15  ioisio
16  iisso
17  iissio
18  iissiio
19  ioiiso
20  iioddo
21  iiodo
22  iioo
23  iioio
24  iioso
25  iiosio
26  iiosiio
27  iiosiiio
28  iioisdo
29  iioiso
30  iiiodddo
31  iiioddo
32  iiiodo
33  iiioo
34  iiioio
35  iiioiio
36  iisiiso
37  iisiisio
38  iiiosdo
39  iiioso
40  iisosso
41  iisossio
42  iisoddo
43  iisodo
44  iisoo
45  iisoio
46  iisoiio
47  iisoiiio
48  iisodsdo
49  iisodso
50  iisiiisio
51  iisiiisiio
52  iisiodddo
53  iisioddo
54  iisiodo
55  iisioo
56  iisioio
57  iisioiio
58  iisioiiio
59  iisioddso
60  iiisdsddddo
61  iiisdsdddo
62  iiisdsddo
63  iiisdsdo
64  iiisdso
65  iiisdsio
66  iisiioo
67  iisiioio
68  iisiioiio
69  iisiioiiio
70  iiisdsiiiiiio
71  iiisdsiiiiiiio
72  iisiiiodddddo
73  iisiiioddddo
74  iisiiiodddo
75  iisiiioddo
76  iisiiiodo
77  iisiiioo
78  iisiiioio
79  iiissddo
80  iiissdo
81  iiisso
82  iiissio
83  iiissiio
84  iiissiiio
85  iiissiiiio
86  iiisdoddo
87  iiisdodo
88  iiisdoo
89  iiisdoio
90  iiisodddddsso
91  iiisodddddssio
92  iiisodddddddo
93  iiisoddddddo
94  iiisodddddo
95  iiisoddddo
96  iiisodddo
97  iiisoddo
98  iiisodo
99  iiisoo
100 iodoo
101 iodoio
102 iodoiio
103 iodoiiio
104 iodoiiso
105 iodoiisio
106 iodoiisiio
107 iiisiodddo
108 iiisioddo
109 iiisiodo
110 ioodo
111 iooo
112 iooio
113 iooiio
114 iooiso
115 iooisio
116 ioisso
117 ioissio
118 ioissiio
119 iooiiso
120 ioioddo
121 ioiodo
122 ioioo
123 ioioio
124 ioioso
125 ioiosio
126 ioiosiio
127 ioiosiiio
128 ioioisdo
129 ioioiso
130 ioiiodddo
131 ioiioddo
132 ioiiodo
133 ioiioo
134 ioiioio
135 ioiioiio
136 ioisiiso
137 ioisiisio
138 ioiiosdo
139 ioiioso
140 ioisosso
141 ioisossio
142 ioisoddo
143 ioisodo
144 ioisoo
145 ioisoio
146 ioisoiio
147 ioisoiiio
148 ioisodsdo
149 ioisodso
150 iissdoiso
151 iissdoisio
152 ioisiodddo
153 ioisioddo
154 ioisiodo
155 ioisioo
156 ioisioio
157 ioisioiio
158 ioisioiiio
159 ioisioddso
160 iissoso
161 iissosio
162 iissosiio
163 ioiisdsdo
164 ioiisdso
165 ioiisdsio
166 ioisiioo
167 ioisiioio
168 ioisiioiio
169 iissdddso
170 iissiodso
171 iissiodsio
172 iissiodsiio
173 iissiodsiiio
174 ioisiiiodddo
175 ioisiiioddo
176 ioisiiiodo
177 ioisiiioo
178 ioisiiioio
179 ioiissddo
180 ioiissdo
181 ioiisso
182 ioiissio
183 ioiissiio
184 ioiissiiio
185 ioiissiiiio
186 ioiisdoddo
187 ioiisdodo
188 ioiisdoo
189 ioiisdoio
190 iissiiiodddso
191 iissddsdddddo
192 iissddsddddo
193 iissddsdddo
194 iissddsddo
195 iissddsdo
196 iissddso
197 iissddsio
198 ioiisodo
199 ioiisoo
200 iioddoo
201 iioddoio
202 iioddoiio
203 iioddoiiio
204 iioddoiiso
205 iioddoiisio
206 iioddoiisiio
207 iioddoiisiiio
208 iioddoiiisdo
209 iioddoiiiso
210 iioisio
211 iiodoo
212 iiodoio
213 iiodoiio
214 iiossddo
215 iiossdo
216 iiosso
217 iiossio
218 iiossiio
219 iiossiiio
220 iiooddo
221 iioodo
222 iiooo
223 iiooio
224 iiooso
225 iioosio
226 iioosiio
227 iioosiiio
228 iiooisdo
229 iiooiso
230 iioiodddo
231 iioioddo
232 iioiodo
233 iioioo
234 iioioio
235 iioioiio
236 iiosiiso
237 iiosiisio
238 iioiosdo
239 iioioso
240 iiososso
241 iiosossio
242 iiosoddo
243 iiosodo
244 iiosoo
245 iiosoio
246 iiosoiio
247 iiosoiiio
248 iiosodsdo
249 iiosodso
250 iiosiiisio
251 iiosiiisiio
252 iiosiodddo
253 iiosioddo
254 iiosiodo
255 iiosioo

ES6 JavaScript 2126 + 311 = 2437 score
m=Math;s=n=>[b=m.min(m.sqrt(n)+.5|0,15),n-b*b];f=n=>(n<0?'d':'i').repeat(m.abs(n));g=(n,t)=>n<4?f(n):g((t=s(n))[0])+'s'+f(t[1]);q=n=>((x=g(n)).length>(z=[...n+''].map((k,i,a)=>i?(a[i-1]==a[i]?'':(y=f((l=s(k))[0]-a[i-1])+(l[0]?'s':'')+f(l[1])).length>m.abs(Q=a[i]-a[i-1])?f(Q):y):g(k)).join('o')).length?z:x)+'o'

Semi-commented:
m = Math; // Keep a reference to math
// This function returns the closest perfect square and the distance from that square to the number
// E.g. s(10) --> [3, 1] because 3^2 + 1 = 10
s = n => [b = m.min(m.sqrt(n) + .5 | 0, 15), n - b * b];
// This creates a bunch of "d"s or "i"s
// E.g. f(3) --> "iii" or f(-2) --> "dd"
f = n => Array(m.abs(n) + 1).join(n < 0 ? 'd' : 'i');
// This constructs the number as a number rather than by digit
g = (n, t) => n < 4 ?
              // If n is less than 4, then we can just increment in normally (base case)
              f(n) :
              // Otherwise, build the square root recursively and shift
              g((t = s(n))[0]) + 's' + f(t[1]);
// This maps based on digits (constructs the number by digit)
// This has now been removed and replaced inline because it is only used once
d = n => (a = [...(n + '')]).map((k, i) => i ? (a[i - 1] == a[i] ? '' : f((l = s(k))[0] - a[i - 1]) + (l[0] ? 's' : '') + f(l[1])) : g(k)).join('o');
// For the official function, compare the digit-method and nondigit-method and return the best one
q = n => ((x = g(n)).length > (z = d(n)).length ? z : x) + 'o'

This takes advantage of the fact that in deadfish, you can print more than one character.
Example: 10 compiles to iodo which is "print one, decrement, print zero."
Usage:
q(10) // --> iodo
q(16) // --> iisso

Here's json data of output:
{
    "0": "o",
    "1": "io",
    "2": "iio",
    "3": "iiio",
    "4": "iiso",
    "5": "iisio",
    "6": "iisiio",
    "7": "iiisddo",
    "8": "iiisdo",
    "9": "iiiso",
    "10": "iodo",
    "11": "ioo",
    "12": "ioio",
    "13": "ioiio",
    "14": "ioiso",
    "15": "iissdo",
    "16": "iisso",
    "17": "iissio",
    "18": "iissiio",
    "19": "ioiiso",
    "20": "iioddo",
    "21": "iiodo",
    "22": "iioo",
    "23": "iioio",
    "24": "iioso",
    "25": "iisiso",
    "26": "iisisio",
    "27": "iisisiio",
    "28": "iioisdo",
    "29": "iioiso",
    "30": "iiiodddo",
    "31": "iiioddo",
    "32": "iiiodo",
    "33": "iiioo",
    "34": "iiioio",
    "35": "iiioiio",
    "36": "iisiiso",
    "37": "iisiisio",
    "38": "iiiosdo",
    "39": "iiioso",
    "40": "iisoddddo",
    "41": "iisodddo",
    "42": "iisoddo",
    "43": "iisodo",
    "44": "iisoo",
    "45": "iisoio",
    "46": "iisoiio",
    "47": "iisoiiio",
    "48": "iisodsdo",
    "49": "iisodso",
    "50": "iiisddsio",
    "51": "iiisddsiio",
    "52": "iisiodddo",
    "53": "iisioddo",
    "54": "iisiodo",
    "55": "iisioo",
    "56": "iisioio",
    "57": "iisioiio",
    "58": "iisioiiio",
    "59": "iisioddso",
    "60": "iiisdsddddo",
    "61": "iiisdsdddo",
    "62": "iiisdsddo",
    "63": "iiisdsdo",
    "64": "iiisdso",
    "65": "iiisdsio",
    "66": "iisiioo",
    "67": "iisiioio",
    "68": "iisiioiio",
    "69": "iisiioiiio",
    "70": "iiisdsiiiiiio",
    "71": "iiisdsiiiiiiio",
    "72": "iiisddodddddo",
    "73": "iiisddoddddo",
    "74": "iiisddodddo",
    "75": "iiisddoddo",
    "76": "iiisddodo",
    "77": "iiisddoo",
    "78": "iiissdddo",
    "79": "iiissddo",
    "80": "iiissdo",
    "81": "iiisso",
    "82": "iiissio",
    "83": "iiissiio",
    "84": "iiissiiio",
    "85": "iiissiiiio",
    "86": "iiisdoddo",
    "87": "iiisdodo",
    "88": "iiisdoo",
    "89": "iiisdoio",
    "90": "iiissiiiiiiiiio",
    "91": "iiisoddddddddo",
    "92": "iiisodddddddo",
    "93": "iiisoddddddo",
    "94": "iiisodddddo",
    "95": "iiisoddddo",
    "96": "iiisodddo",
    "97": "iiisoddo",
    "98": "iiisodo",
    "99": "iiisoo",
    "100": "iodoo",
    "101": "iodoio",
    "102": "iodoiio",
    "103": "iodoiiio",
    "104": "iodoiiso",
    "105": "iodoiisio",
    "106": "iodoiisiio",
    "107": "iodoiiisddo",
    "108": "iodoiiisdo",
    "109": "iodoiiiso",
    "110": "ioodo",
    "111": "iooo",
    "112": "iooio",
    "113": "iooiio",
    "114": "iooiso",
    "115": "iooisio",
    "116": "iooisiio",
    "117": "iooiisddo",
    "118": "iooiisdo",
    "119": "iooiiso",
    "120": "ioioddo",
    "121": "ioiodo",
    "122": "ioioo",
    "123": "ioioio",
    "124": "ioioso",
    "125": "ioiosio",
    "126": "ioiosiio",
    "127": "ioioisddo",
    "128": "ioioisdo",
    "129": "ioioiso",
    "130": "ioiiodddo",
    "131": "ioiioddo",
    "132": "ioiiodo",
    "133": "ioiioo",
    "134": "ioiioio",
    "135": "ioiioiio",
    "136": "ioiioiiio",
    "137": "ioiiosddo",
    "138": "ioiiosdo",
    "139": "ioiioso",
    "140": "ioisoddddo",
    "141": "ioisodddo",
    "142": "ioisoddo",
    "143": "ioisodo",
    "144": "ioisoo",
    "145": "ioisoio",
    "146": "ioisoiio",
    "147": "ioisoiiio",
    "148": "ioisodsdo",
    "149": "ioisodso",
    "150": "ioisiodddddo",
    "151": "ioisioddddo",
    "152": "ioisiodddo",
    "153": "ioisioddo",
    "154": "ioisiodo",
    "155": "ioisioo",
    "156": "ioisioio",
    "157": "ioisioiio",
    "158": "ioisioiiio",
    "159": "ioisioddso",
    "160": "ioisiioddddddo",
    "161": "ioisiiodddddo",
    "162": "ioisiioddddo",
    "163": "ioisiiodddo",
    "164": "ioisiioddo",
    "165": "ioisiiodo",
    "166": "ioisiioo",
    "167": "ioisiioio",
    "168": "iissdddsdo",
    "169": "iissdddso",
    "170": "iissdddsio",
    "171": "iissdddsiio",
    "172": "iissdddsiiio",
    "173": "iissdddsiiiio",
    "174": "ioiisddodddo",
    "175": "ioiisddoddo",
    "176": "ioiisddodo",
    "177": "ioiisddoo",
    "178": "ioiisddoio",
    "179": "ioiisddoiio",
    "180": "ioiisdoddddddddo",
    "181": "ioiisdodddddddo",
    "182": "ioiisdoddddddo",
    "183": "ioiisdodddddo",
    "184": "ioiisdoddddo",
    "185": "ioiisdodddo",
    "186": "ioiisdoddo",
    "187": "ioiisdodo",
    "188": "ioiisdoo",
    "189": "ioiisdoio",
    "190": "iissddsddddddo",
    "191": "iissddsdddddo",
    "192": "iissddsddddo",
    "193": "iissddsdddo",
    "194": "iissddsddo",
    "195": "iissddsdo",
    "196": "iissddso",
    "197": "iissddsio",
    "198": "ioiisodo",
    "199": "ioiisoo",
    "200": "iioddoo",
    "201": "iioddoio",
    "202": "iioddoiio",
    "203": "iioddoiiio",
    "204": "iioddoiiso",
    "205": "iioddoiisio",
    "206": "iioddoiisiio",
    "207": "iioddoiiisddo",
    "208": "iioddoiiisdo",
    "209": "iioddoiiiso",
    "210": "iiododo",
    "211": "iiodoo",
    "212": "iiodoio",
    "213": "iiodoiio",
    "214": "iiodoiso",
    "215": "iiodoisio",
    "216": "iiodoisiio",
    "217": "iiodoiisddo",
    "218": "iiodoiisdo",
    "219": "iiodoiiso",
    "220": "iiooddo",
    "221": "iioodo",
    "222": "iiooo",
    "223": "iiooio",
    "224": "iiooso",
    "225": "iissdso",
    "226": "iissdsio",
    "227": "iissdsiio",
    "228": "iiooisdo",
    "229": "iiooiso",
    "230": "iioiodddo",
    "231": "iioioddo",
    "232": "iioiodo",
    "233": "iioioo",
    "234": "iioioio",
    "235": "iioioiio",
    "236": "iioioiiio",
    "237": "iioiosddo",
    "238": "iioiosdo",
    "239": "iioioso",
    "240": "iiosoddddo",
    "241": "iiosodddo",
    "242": "iiosoddo",
    "243": "iiosodo",
    "244": "iiosoo",
    "245": "iiosoio",
    "246": "iiosoiio",
    "247": "iiosoiiio",
    "248": "iiosodsdo",
    "249": "iiosodso",
    "250": "iiosiodddddo",
    "251": "iiosioddddo",
    "252": "iiosiodddo",
    "253": "iiosioddo",
    "254": "iiosiodo",
    "255": "iiosioo"
}

That was generated by this code:
var c = {}, result = 0;
for (var i = 0; i <= 255; ++i) result += (c[i] = q(i)).length;

which prints result = (the result) and c = the thing above.
This gets a remarkably high score despite being pretty simple. It searches for the nearest perfect square, calculates the square root of that perfect square, adds 's', and increments/decrements appropriately.
Old version which didn't use the fact that "10" = "print one, print zero"
m=Math;s=n=>[b=m.sqrt(n)+.5|0,n-b*b];f=(n)=>Array(m.abs(n)+1).join('id'[+(n<0)]);g=(n,t)=>n<4?f(n):g((t=s(n))[0])+'s'+f(t[1]);q=n=>g(n)+'o'

You appear to have gotten the effect of the d operation wrong - if it decrements to -1, it gets reset to 0, not 255.

@Doorknob slap in the forehead thanks! Fixed now (had to increase score by 15)

I think you misunderstood what o does; it outputs the accumulator and a newline. iodo outputs 1\n0\n, not 10.

Invalid for many numbers (due to 256 and -1 -> 0). Example 255 iissdo: i:1,i:2,s:4,s:16,s:256->0,d:-1->0,output 0

@Gabe the wiki page for Deadfish does not mention that a newline will also be printed when doing o. Neither does many compilers (in different languages) print a new line with o

@Optimizer: I think the newline is implied. I don't know all 60+ languages that have versions on the wiki page, but it looks like all the ones I can read do it: Bash, C (the reference implementation), C#, C++, Clever, C64 BASIC, Go, Haskell, HTML/JS, Java, Obfuscated C, OCaml, Pascal, Perl, Python, R, Ruby, Rust, Scheme, Seed7, Stackstack, Unofficial MagicKit Assembler, VB.NET, WTFZOMFG. The important thing is that this answer generates programs that don't work on the reference implementation.

@edc65 Updated.

Haskell, 2200 2177 2171 = 2036 + 135
f n=[s|s<-l,s%0==show n]!!0
l="":[c:x|x<-l,c<-"iosd"]
(h:s)%n|h<'e'=s%(n-1)|h<'j'=s%(n+1)|h<'p'=show n++s%n|n==16=s%0|0<1=s%(n^2)
x%_=x

this works by having an infinite list of all deadfish programs, sorted by their length, accompanied by the internal state and the output. the function f searches the list and returns the first entry that matches.
this approach allows for for multiple o in each resulting code, but does not restrict it to either printing all the digits separately, or printing the whole number at once. for example, here 216 has the code of iiosso.
Edit:
according to the spec, when the state is 256 (but not 257) it is made into a 0. now my code takes this into account. for example, 160 is iissoso.
this has a few efficiency problems; because l is a top-level list, all the elements of l which have been evaluated stay in memory, and so runtime will probably be out of memory at some point.
to calculate the score, I made an equivalent-but-less-memory-heavy version.
my more-efficient code works by recomputing the list on every application of f, so that the garbage collector can throw the already searched part of the list away. in a sense, this is breadth-first search using laziness.
the more-efficient code also adds some more constraints to the elements of the list - it filters out all codes that contain id or di, or contains an s when the state is smaller than 2.
Edit:
I moved the g function from the top level to being a helper function to
f', so now g filters codes that printed something which isn't a prefix of our wanted number. now the code is much faster.
the more-efficient code:
f' n=[reverse s|(s,_,r)<-l,r==show n]!!0 where
    l=("",0,""):l>>= \(i,s,r)->filter g[('i':i,s+1,r),('o':i,s,r++show s),('s':i,if s==16 then 0 else s*s,r),('d':i,s-1,r)]
    g('i':'d':_,_,_)=False
    g('d':'i':_,_,_)=False
    g('i':'i':_,4,_)=False
    g('s':_,1,_)=False
    g("s",_,_)=False
    g("si",_,_)=False
    g(i,s,r)=s<256&&s>=0&&isPrefixOf r (show n)

note the more-efficient code will not have the same results because the programs traverse all the possible codes in different order. however, they will output codes of the same length. also, switching c:x with x++[c] makes the programs equivalent.
with this code i was able to compute all the programs in 52 0.81 seconds.
Edit:
apparently this is the best answer! i noticed it just now, so far from when this was asked...
the results:
1   io
2   iio
3   iiio
4   iiso
5   iisio
6   iisiio
7   iiisddo
8   iiisdo
9   iiiso
10  iodo
11  ioo
12  ioio
13  ioiio
14  ioiso
15  iissdo
16  iisso
17  iissio
18  iissiio
19  ioiiso
20  iioddo
21  iiodo
22  iioo
23  iioio
24  iioso
25  iiosio
26  iiosiio
27  iioisddo
28  iioisdo
29  iioiso
30  iiioisso
31  iiioddo
32  iiiodo
33  iiioo
34  iiioio
35  iiioiio
36  iisiiso
37  iiiosddo
38  iiiosdo
39  iiioso
40  iisosso
41  iisossio
42  iisoddo
43  iisodo
44  iisoo
45  iisoio
46  iisoiio
47  iisoiiio
48  iisodsdo
49  iisodso
50  iiisddsio
51  iiisddsiio
52  iisiodddo
53  iisioddo
54  iisiodo
55  iisioo
56  iisioio
57  iisioiio
58  iisioiiio
59  iisioddso
60  iiisdsddddo
61  iiisdsdddo
62  iiisdsddo
63  iiisdsdo
64  iiisdso
65  iiisdsio
66  iisiioo
67  iisiioio
68  iisiioiio
69  iisiioiiio
70  iiisdsiiiiiio
71  iiisdsiiiiiiio
72  iiisddodddddo
73  iiisddoddddo
74  iiisddodddo
75  iiisddoddo
76  iiisddodo
77  iiisddoo
78  iiissdddo
79  iiissddo
80  iiissdo
81  iiisso
82  iiissio
83  iiissiio
84  iiissiiio
85  iiissiiiio
86  iiisdoddo
87  iiisdodo
88  iiisdoo
89  iiisdoio
90  iiisodddddsso
91  iiisodddddssio
92  iiisodddddddo
93  iiisoddddddo
94  iiisodddddo
95  iiisoddddo
96  iiisodddo
97  iiisoddo
98  iiisodo
99  iiisoo
100 iodoo
101 iodoio
102 iodoiio
103 iodoiiio
104 iodoiiso
105 iodoiisio
106 iodoiisiio
107 iiisiodddo
108 iiisioddo
109 iiisiodo
110 ioodo
111 iooo
112 iooio
113 iooiio
114 iooiso
115 ioissdo
116 ioisso
117 ioissio
118 ioissiio
119 iooiiso
120 ioioddo
121 ioiodo
122 ioioo
123 ioioio
124 ioioso
125 ioiosio
126 ioiosiio
127 ioioisddo
128 ioioisdo
129 ioioiso
130 ioiioisso
131 ioiioddo
132 ioiiodo
133 ioiioo
134 ioiioio
135 ioiioiio
136 ioisiiso
137 ioiiosddo
138 ioiiosdo
139 ioiioso
140 ioisosso
141 ioisossio
142 ioisoddo
143 ioisodo
144 ioisoo
145 ioisoio
146 ioisoiio
147 ioisoiiio
148 ioisodsdo
149 ioisodso
150 iissdoiso
151 iissdoisio
152 ioisiodddo
153 ioisioddo
154 ioisiodo
155 ioisioo
156 ioisioio
157 ioisioiio
158 ioisioiiio
159 ioisioddso
160 iissoso
161 iissosio
162 iissosiio
163 ioiisdsdo
164 ioiisdso
165 ioiisdsio
166 ioisiioo
167 ioisiioio
168 iissdddsdo
169 iissdddso
170 iissiodso
171 iissiodsio
172 iissiodsiio
173 iissiodsiiio
174 iissiodsiiso
175 ioiisddoddo
176 ioiisddodo
177 ioiisddoo
178 ioiissdddo
179 ioiissddo
180 ioiissdo
181 ioiisso
182 ioiissio
183 ioiissiio
184 ioiissiiio
185 ioiissiiiio
186 ioiisdoddo
187 ioiisdodo
188 ioiisdoo
189 ioiisdoio
190 iissiiiodddso
191 iissddsdddddo
192 iissddsddddo
193 iissddsdddo
194 iissddsddo
195 iissddsdo
196 iissddso
197 iissddsio
198 ioiisodo
199 ioiisoo
200 iioddoo
201 iioddoio
202 iioddoiio
203 iioddoiiio
204 iioddoiiso
205 iioddoiisio
206 iioddoiisiio
207 iioddoiiisddo
208 iioddoiiisdo
209 iioddoiiiso
210 iioisio
211 iiodoo
212 iiodoio
213 iiodoiio
214 iiossddo
215 iiossdo
216 iiosso
217 iiossio
218 iiossiio
219 iiossiiio
220 iiooddo
221 iioodo
222 iiooo
223 iiooio
224 iiooso
225 iioosio
226 iioosiio
227 iiooisddo
228 iiooisdo
229 iiooiso
230 iioioisso
231 iioioddo
232 iioiodo
233 iioioo
234 iioioio
235 iioioiio
236 iiosiiso
237 iioiosddo
238 iioiosdo
239 iioioso
240 iiososso
241 iiosossio
242 iiosoddo
243 iiosodo
244 iiosoo
245 iiosoio
246 iiosoiio
247 iiosoiiio
248 iiosodsdo
249 iiosodso
250 iioisddsio
251 iioisddsiio
252 iiosiodddo
253 iiosioddo
254 iiosiodo
255 iiosioo

Mathematica, 254 165 characters + 3455 = 3620
f@n_:=n;g@0="";l={f@0=0};h=If[f@#>f@i&&#<256&&#>0,f@#=f@i+1;g@#=g@i<>#2;l~AppendTo~#]&;While[l!={},i=#&@@l;l=Rest@l;h[i+1,"i"];h[i-1,"d"];h[i*i,"s"];];g@Input[]<>"o"

Less golf:
f@n_ := n;
g@0 = "";
l = {f@0 = 0};
h = If[f@# > f@i && # < 256 && # > 0,
    f@# = f@i + 1;
    g@# = g@i <> #2;
    l~AppendTo~#] &;
While[l != {},
  i = # & @@ l;
  l = Rest@l;
  h[i + 1, "i"];
  h[i - 1, "d"];
  h[i*i, "s"];
  ];
g@Input[] <> "o"

I believe the resulting numbers are optimal. This is doing a breadth-first search over all 256 numbers, keeping track of the shortest way it has found to represent each number. The search is building a sort of lookup table in the function g which is then applied to the input.
For reference, here are all 255 results:
io
iio
iiio
iiso
iisio
iisiio
iisiiio
iiisdo
iiiso
iiisio
iiisiio
iiisiiio
iissdddo
iissddo
iissdo
iisso
iissio
iissiio
iissiiio
iissiiiio
iissiiiiio
iisisdddo
iisisddo
iisisdo
iisiso
iisisio
iisisiio
iisisiiio
iisisiiiio
iisisiiiiio
iisisiiiiiio
iisiisddddo
iisiisdddo
iisiisddo
iisiisdo
iisiiso
iisiisio
iisiisiio
iisiisiiio
iisiisiiiio
iisiisiiiiio
iisiisiiiiiio
iisiisiiiiiiio
iisiiisdddddo
iisiiisddddo
iisiiisdddo
iisiiisddo
iisiiisdo
iisiiiso
iisiiisio
iisiiisiio
iisiiisiiio
iisiiisiiiio
iisiiisiiiiio
iisiiisiiiiiio
iisiiisiiiiiiio
iiisdsdddddddo
iiisdsddddddo
iiisdsdddddo
iiisdsddddo
iiisdsdddo
iiisdsddo
iiisdsdo
iiisdso
iiisdsio
iiisdsiio
iiisdsiiio
iiisdsiiiio
iiisdsiiiiio
iiisdsiiiiiio
iiisdsiiiiiiio
iiissdddddddddo
iiissddddddddo
iiissdddddddo
iiissddddddo
iiissdddddo
iiissddddo
iiissdddo
iiissddo
iiissdo
iiisso
iiissio
iiissiio
iiissiiio
iiissiiiio
iiissiiiiio
iiissiiiiiio
iiissiiiiiiio
iiissiiiiiiiio
iiissiiiiiiiiio
iiissiiiiiiiiiio
iiisisddddddddo
iiisisdddddddo
iiisisddddddo
iiisisdddddo
iiisisddddo
iiisisdddo
iiisisddo
iiisisdo
iiisiso
iiisisio
iiisisiio
iiisisiiio
iiisisiiiio
iiisisiiiiio
iiisisiiiiiio
iiisisiiiiiiio
iiisisiiiiiiiio
iiisisiiiiiiiiio
iiisisiiiiiiiiiio
iiisisiiiiiiiiiiio
iiisiisdddddddddo
iiisiisddddddddo
iiisiisdddddddo
iiisiisddddddo
iiisiisdddddo
iiisiisddddo
iiisiisdddo
iiisiisddo
iiisiisdo
iiisiiso
iiisiisio
iiisiisiio
iiisiisiiio
iiisiisiiiio
iiisiisiiiiio
iiisiisiiiiiio
iiisiisiiiiiiio
iiisiisiiiiiiiio
iiisiisiiiiiiiiio
iiisiisiiiiiiiiiio
iiisiisiiiiiiiiiiio
iiisiisiiiiiiiiiiiio
iiisiiisddddddddddo
iiisiiisdddddddddo
iiisiiisddddddddo
iiisiiisdddddddo
iiisiiisddddddo
iiisiiisdddddo
iiisiiisddddo
iiisiiisdddo
iiisiiisddo
iiisiiisdo
iiisiiiso
iiisiiisio
iiisiiisiio
iiisiiisiiio
iiisiiisiiiio
iiisiiisiiiiio
iiisiiisiiiiiio
iiisiiisiiiiiiio
iiisiiisiiiiiiiio
iiisiiisiiiiiiiiio
iiisiiisiiiiiiiiiio
iiisiiisiiiiiiiiiiio
iiisiiisiiiiiiiiiiiio
iissdddsddddddddddddo
iissdddsdddddddddddo
iissdddsddddddddddo
iissdddsdddddddddo
iissdddsddddddddo
iissdddsdddddddo
iissdddsddddddo
iissdddsdddddo
iissdddsddddo
iissdddsdddo
iissdddsddo
iissdddsdo
iissdddso
iissdddsio
iissdddsiio
iissdddsiiio
iissdddsiiiio
iissdddsiiiiio
iissdddsiiiiiio
iissdddsiiiiiiio
iissdddsiiiiiiiio
iissdddsiiiiiiiiio
iissdddsiiiiiiiiiio
iissdddsiiiiiiiiiiio
iissdddsiiiiiiiiiiiio
iissddsddddddddddddddo
iissddsdddddddddddddo
iissddsddddddddddddo
iissddsdddddddddddo
iissddsddddddddddo
iissddsdddddddddo
iissddsddddddddo
iissddsdddddddo
iissddsddddddo
iissddsdddddo
iissddsddddo
iissddsdddo
iissddsddo
iissddsdo
iissddso
iissddsio
iissddsiio
iissddsiiio
iissddsiiiio
iissddsiiiiio
iissddsiiiiiio
iissddsiiiiiiio
iissddsiiiiiiiio
iissddsiiiiiiiiio
iissddsiiiiiiiiiio
iissddsiiiiiiiiiiio
iissddsiiiiiiiiiiiio
iissddsiiiiiiiiiiiiio
iissdsdddddddddddddddo
iissdsddddddddddddddo
iissdsdddddddddddddo
iissdsddddddddddddo
iissdsdddddddddddo
iissdsddddddddddo
iissdsdddddddddo
iissdsddddddddo
iissdsdddddddo
iissdsddddddo
iissdsdddddo
iissdsddddo
iissdsdddo
iissdsddo
iissdsdo
iissdso
iissdsio
iissdsiio
iissdsiiio
iissdsiiiio
iissdsiiiiio
iissdsiiiiiio
iissdsiiiiiiio
iissdsiiiiiiiio
iissdsiiiiiiiiio
iissdsiiiiiiiiiio
iissdsiiiiiiiiiiio
iissdsiiiiiiiiiiiio
iissdsiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiiio
iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiiiio

I am not certain I like the scoring that much myself...do you have a better idea for how to do it?

@MegaTom As I suggested in the comments: the sum of the lengths of all 256 numbers.

in that case should you multiply the char count by 5 or something like that? otherwise it will soon be irrelevant.

@MegaTom Depends on whether you want to encourage heuristic-based solutions. If not then it doesn't matter, because everyone will probably try to golf down the optimal solution. In that case it doesn't matter how far apart different character counts are. If you do want heuristic solutions, you'll have to increase the character count by a lot more than a factor of 5. More like 35. The total length of strings I get is 3456.

OK, I changed the scoring. See above.

This is definitely not optimal - 255 can be represented as iisssdo instead of iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiiiio, for instance. I think if you allow 256 as an intermediate step, that should fix the issue.

@isaacg Whoops, of course. Thank you, I fixed it.

Actually, 255 can even be shortened to do because deadfish wraps around for negative numbers.

@soktinpk According to Sp3000's comment it doesn't, but that still makes my answer wrong because I can't make use of 256 at all.

No, Sp3000 said "If you hit -1 OR 256, then it gets reset to 0. But if you hit a number bigger than 256 by squaring then it's unchanged, e.g. 17^2 = 289". So if you get to 256 by squaring, it's okay. On the other hand, If you call d where accumulator is zero, then it wraps to 255.

@soktinpk I read "if you hit a number bigger than 256 by squaring" as n > 256 not n ≥ 256. And that's also in line with the esolang page: " Although the comment in the C implementation states /* Make sure x is not greater then [sic] 256 */, the implementation sets the value to zero if and only if value == -1 || value == 256."

@MartinBüttner I see. That's a good point, but do should still output 255, right?

@soktinpk no, you're hitting -1 with d, so that should print 0.

Should score 1 less, as the range is 'all numbers from 1-255' (3455)

@edc65 Thanks, fixed.

C, 433 code + 3455 output = 3888
C++, 430 code + 3455 output = 3885
And now for something completely different.
I used the output from Martin's Mathematica answer (updated on October 23rd as it was wrong for 240+ before).  My output is the same 3455 characters.  I analyzed patterns in the output and discovered that [0,255] can be represented by this sequence:

0-3 is
0-2 ss
0-3 is or ds
0-1 ss
0-14 i or 0-16 ds
1 o

The next step was to carefully construct these five columns (c through g in the code below).  I used negative numbers to indicate d instead of i in columns e and g.  Then, it turns out that the results work mostly like a counter in the g column, since each row u usually removes one d or adds one i relative to the previous row (v).  There are 15 exceptions, which are stored in x (the indexes) and b (the five columns, packed into an integer which only requires 14 bits to store the maximum 10832).
For example, the first "exception" is the very first row, where we want zero characters apart from the terminating o.  So x[0] is 0, and b[0] is 544, which when unpacked is ("little endian" style, since g is the counting column) { 32, 0, 4, 0, 0 }.  We always subtract 32 from g and 4 from e to make the unsigned bit-fields work (i.e. those two columns represent negative numbers conceptually when d is required instead of i, but in the implementation the values are offset to avoid actual negative numbers).
Here's a table showing how the first ten numbers work (blanks are zeros):
n   text    c   d   e   f   g
0   o
1   io                      1
2   iio                     2
3   iiio                    3
4   iiso    2   1
5   iisio   2   1           1
6   iisiio  2   1           2
7   iisiiio 2   1           3
8   iiisdo  3   1          -1
9   iiiso   3   1

You can see that g mostly just increments by one for each new row, but some rows (0, 4, 8, ..., which I briefly hoped to find in OEIS) "reset" the sequence, meaning g takes on some new value and at least one other column is modified as well.
The code character count excludes whitespace except the mandatory newline before each # and space after unsigned and int.  You can save 3 characters by compiling as C++ instead of C, replacing <stdio.h> with <cstdio>, and *(int*)&u with (int&)u.
#include <stdio.h>

struct { unsigned g:6, f:1, e:3, d:2, c:2; } u;

int
  x[] = { 0,4,8,13,22,32,44,57,72,92,112,134,157,182,210,256 },
  b[] = { 544,9760,13855,9821,9949,10076,10203,13785,13911,14040,14167,14294,10452,10578,10705,10832 };

int main()
{
  int n,i=0,q=0;
  scanf("%d", &n);
  while(i++ <= n) {
    ++u.g;
    if (i > x[q])
      *(int*)&u = b[q++];
  }

#define m(p, q) while (p) putchar(#q[0]);

  m(u.c--, i)
  m(u.d--, s)
  m(u.e++ < 4, d)
  m(--u.e > 4, i)
  m(u.f--, s)
  m(u.g++ < 32, d)
  m(--u.g > 32, i)
  puts("o");
}

A fun fact about this code: an earlier version used an array of 256 unions instead of just u and v.  That version caused GCC 4.7.2 to generate an internal compiler error!  GCC 4.9 fixed it, however, and the above code works with either version.

The program has to input the number, not iterate over [0...255] (replace for(...) with scanf - this would decrease character count).

Also, maybe replacing C99 by a more relaxed language could get rid of #include, and maybe you could make the struct inside the union unnamed.

@anatolyg: thanks, I fixed the program to take a number from stdin instead of always printing [0,255].  The for loop is still required due to the way I compute the result.  This plus unnaming the struct saved 5 characters; another 2 were saved by changing == to > and removing the trailing newline.  :) The program is only fully valid in C99, because main does not explicitly return a value; removing the #include results in an error due to scanf() now.

My output was actually wrong, because you can't make use of 256.

@MartinBüttner: thank you for the comment.  I've updated the lookup tables in my code to match your new output in [240,255].  This cost me a few characters because many constants grew from 4 to 5 bytes, not to mention the output is longer now, but at least it's correct now.  I also changed the title from "C99" to "C" since I no longer make use of C99-specific features.

Picat 516 + 2060 = 2576
It is somewhat modified version  of Sergey Dymchenko program. This version outputs more compact deadfish programs.
import planner.
final((N,N))=>true.
action((N,A),B,M,C)?=>B=(N,A+1),M=i,C=1.
action((N,A),B,M,C)?=>A!=16,A<N,B=(N,A*A),M=s,C=1.
action((N,A),B,M,C)?=>A>0,B=(N,A-1),M=d,C=1.
r([X,Y|Z],A)?=>(r([Y|Z],R),A=[X|R];X!=['0'],r([(X++Y)|Z],R),A=R).
r([],A)=>A=[]. r([N],A)=>A=[N]. lf(X)=[X].
table(+,-,min) fs(N,M,L)=>r(map(lf,N.to_string()),X),Np:=0,Pp:=[],
foreach(Y in X)N:=Y.to_integer(),best_plan((N,Np),P),Np:=N,Pp:=Pp++P++[o]
end,L=Pp.length(),M=Pp. main=>foreach(X in 1..255)fs(X,P,L),printf("%s",P) end.

As far as I understood "lengths of outputs" sentence, it means that I should sum output without new-line chars.
Use:
picat filename.pi

1-255 Codes:
picat filename.pi | wc -c

2060

Performance:
cat /proc/cpuinfo # 4 cores with HT = virtual 8 cores

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
stepping    : 7
physical id : 0
siblings    : 8
core id     : 1
cpu cores   : 4
apicid      : 2
cpu MHz     : 1600.000
cache size  : 8192 KB
...
bogomips    : 6819.33
...

Version of program to measure time:
import planner.
import sys.
final((N,N))=>true.
action((N,A),B,M,C)?=>B=(N,A+1), M=i, C=1.
action((N,A),B,M,C)?=>A!=16, A<N, B=(N,A*A), M=s, C=1.
action((N,A),B,M,C)?=>A>0, B=(N,A-1), M=d, C=1.
r([X,Y|Z],A)?=>(r([Y|Z],R),A=[X|R];r([(X++Y)|Z],R),A=R).
r([],A)=>A=[]. r([N],A)=>A=[N]. lf(X)=[X].
table(+,-,min) fs(N,M,L)=>r(map(lf,N.to_string()),X),Np:=0,Pp:=[],
foreach(Y in X)N:=Y.to_integer(),best_plan((N,Np),P),Np:=N,Pp:=Pp++P++[o]
end,L=Pp.length(),M=Pp. go=>foreach(X in 1..255)fs(X,P,L),printf("%d %s",X,P),nl end.
main=>time2(go).

Result:
picat filename.pi

...

251 iiosioddddo
252 iiosiodddo
253 iiosioddo
254 iiosiodo
255 iiosioo

CPU time 2.2 seconds. Backtracks: 0

Full output:
1 io
2 iio
3 iiio
4 iiso
5 iisio
6 iisiio
7 iiisddo
8 iiisdo
9 iiiso
10 iodo
11 ioo
12 ioio
13 ioiio
14 ioiso
15 ioisio
16 iisso
17 iissio
18 ioiisdo
19 ioiiso
20 iioddo
21 iiodo
22 iioo
23 iioio
24 iioso
25 iiosio
26 iiosiio
27 iioisddo
28 iioisdo
29 iioiso
30 iiiodddo
31 iiioddo
32 iiiodo
33 iiioo
34 iiioio
35 iiioiio
36 iisiiso
37 iiiosddo
38 iiiosdo
39 iiioso
40 iisoddddo
41 iisodddo
42 iisoddo
43 iisodo
44 iisoo
45 iisoio
46 iisoiio
47 iisoiiio
48 iisodsdo
49 iisodso
50 iiisddsio
51 iisioddddo
52 iisiodddo
53 iisioddo
54 iisiodo
55 iisioo
56 iisioio
57 iisioiio
58 iisioiiio
59 iisioddso
60 iiisdsddddo
61 iiisdsdddo
62 iiisdsddo
63 iiisdsdo
64 iiisdso
65 iisiiodo
66 iisiioo
67 iisiioio
68 iisiioiio
69 iisiioiiio
70 iiisdsiiiiiio
71 iiisddoddddddo
72 iiisddodddddo
73 iiisddoddddo
74 iiisddodddo
75 iiisddoddo
76 iiisddodo
77 iiisddoo
78 iiisddoio
79 iiissddo
80 iiissdo
81 iiisso
82 iiissio
83 iiissiio
84 iiissiiio
85 iiisdodddo
86 iiisdoddo
87 iiisdodo
88 iiisdoo
89 iiisdoio
90 iiisodddddddddo
91 iiisoddddddddo
92 iiisodddddddo
93 iiisoddddddo
94 iiisodddddo
95 iiisoddddo
96 iiisodddo
97 iiisoddo
98 iiisodo
99 iiisoo
100 iodoo
101 iodoio
102 iodoiio
103 iodoiiio
104 iodoiiso
105 iodoiisio
106 iodoiisiio
107 iiisiodddo
108 iiisioddo
109 iiisiodo
110 ioodo
111 iooo
112 iooio
113 iooiio
114 iooiso
115 iooisio
116 ioisso
117 ioissio
118 iooiisdo
119 iooiiso
120 ioioddo
121 ioiodo
122 ioioo
123 ioioio
124 ioioso
125 ioiosio
126 ioiosiio
127 ioioisddo
128 ioioisdo
129 ioioiso
130 ioiiodddo
131 ioiioddo
132 ioiiodo
133 ioiioo
134 ioiioio
135 ioiioiio
136 ioisiiso
137 ioiiosddo
138 ioiiosdo
139 ioiioso
140 ioisoddddo
141 ioisodddo
142 ioisoddo
143 ioisodo
144 ioisoo
145 ioisoio
146 ioisoiio
147 ioisoiiio
148 ioisodsdo
149 ioisodso
150 ioiisddsio
151 ioisioddddo
152 ioisiodddo
153 ioisioddo
154 ioisiodo
155 ioisioo
156 ioisioio
157 ioisioiio
158 ioisioiiio
159 ioisioddso
160 ioiisdsddddo
161 ioiisdsdddo
162 ioiisdsddo
163 ioiisdsdo
164 ioiisdso
165 ioisiiodo
166 ioisiioo
167 ioisiioio
168 ioisiioiio
169 iissdddso
170 iissdddsio
171 iissdddsiio
172 iissdddsiiio
173 ioiisddoddddo
174 ioiisddodddo
175 ioiisddoddo
176 ioiisddodo
177 ioiisddoo
178 ioiisddoio
179 ioiissddo
180 ioiissdo
181 ioiisso
182 ioiissio
183 ioiissiio
184 ioiissiiio
185 ioiisdodddo
186 ioiisdoddo
187 ioiisdodo
188 ioiisdoo
189 ioiisdoio
190 iissddsddddddo
191 iissddsdddddo
192 iissddsddddo
193 iissddsdddo
194 iissddsddo
195 iissddsdo
196 iissddso
197 ioiisoddo
198 ioiisodo
199 ioiisoo
200 iioddoo
201 iioddoio
202 iioddoiio
203 iioddoiiio
204 iioddoiiso
205 iioddoiisio
206 iioddoiisiio
207 iioddoiiisddo
208 iioddoiiisdo
209 iioddoiiiso
210 iiododo
211 iiodoo
212 iiodoio
213 iiodoiio
214 iiodoiso
215 iiossdo
216 iiosso
217 iiossio
218 iiossiio
219 iiodoiiso
220 iiooddo
221 iioodo
222 iiooo
223 iiooio
224 iiooso
225 iioosio
226 iioosiio
227 iiooisddo
228 iiooisdo
229 iiooiso
230 iioiodddo
231 iioioddo
232 iioiodo
233 iioioo
234 iioioio
235 iioioiio
236 iiosiiso
237 iioiosddo
238 iioiosdo
239 iioioso
240 iiosoddddo
241 iiosodddo
242 iiosoddo
243 iiosodo
244 iiosoo
245 iiosoio
246 iiosoiio
247 iiosoiiio
248 iiosodsdo
249 iiosodso
250 iioisddsio
251 iiosioddddo
252 iiosiodddo
253 iiosioddo
254 iiosiodo
255 iiosioo

Is the last example you gave supposed to print 255? If so, it seems you didn't understand the o operation - it prints the current number, bit doesn't reset it, so ioio would print "12"  and not "11"

Thanks to proud haskeller for pointing to my misunderstanding. I've corrected program.

Prolog, 621 + 2036 - 100 = 2557
Here is a backward search, memoization solution in Prolog:
x(N,R):-between(1,inf,D),y(N,O,M),z(M,O,D,L),!,reverse([o|L],R).
:-dynamic t/4.
z(N,O,D,L):-t(N,O,D,L),!,L\==s.
z(N,O,D,L):-u(N,O,D,L),!,assertz(t(N,O,D,L)).
z(N,O,D,_):-assertz(t(N,O,D,s)),fail.
u(N,O,0,[]):-!,N=0,O=0.
u(N,O,D,[C|L]):-E is D-1,member(C,[s,o,i,d]),v(C,N,O,M,P),z(M,P,E,L),!.
v(s,N,O,M,O):-(N=0->M=16;H is sqrt(N),M is truncate(H),H is float(M)).
v(o,N,O,N,P):-y(O,P,R),R=N,!.
v(i,N,O,M,O):-(N=0->M=255;M is N-1).
v(d,N,O,M,O):-M is N+1.
y(N,0,N):-N<10,!.
y(N,P,R):-divmod(N,10,D,M),(P=D,R=M;y(D,P,Q),Q\==0,R is Q*10+M).
w:-between(1,255,N),x(N,L),atom_chars(A,L),write(A),nl,fail.
w.
:-initialization(w).

Dry run takes only 0.055 seconds! Numbered output lines:
1 io
2 iio
3 iiio
4 iiso
5 iisio
6 iisiio
7 iisiiio
8 iiisdo
9 iiiso
10 iodo
11 ioo
12 ioio
13 ioiio
14 ioiso
15 ioisio
16 iisso
17 iissio
18 ioiisdo
19 ioiiso
20 iioddo
21 iiodo
22 iioo
23 iioio
24 iioso
25 iiosio
26 iiosiio
27 iiosiiio
28 iioisdo
29 iioiso
30 iiioisso
31 iiioddo
32 iiiodo
33 iiioo
34 iiioio
35 iiioiio
36 iisiiso
37 iiiosddo
38 iiiosdo
39 iiioso
40 iisosso
41 iisossio
42 iisoddo
43 iisodo
44 iisoo
45 iisoio
46 iisoiio
47 iisoiiio
48 iisodsdo
49 iisodso
50 iisiodsso
51 iisiodssio
52 iisiodddo
53 iisioddo
54 iisiodo
55 iisioo
56 iisioio
57 iisioiio
58 iisioiiio
59 iisioddso
60 iisiioddsso
61 iiisdsdddo
62 iiisdsddo
63 iiisdsdo
64 iiisdso
65 iisiiodo
66 iisiioo
67 iisiioio
68 iisiioiio
69 iisiioiiio
70 iisiiiodddsso
71 iisiiiodddssio
72 iisiiiodddddo
73 iisiiioddddo
74 iisiiiodddo
75 iisiiioddo
76 iisiiiodo
77 iisiiioo
78 iisiiioio
79 iiissddo
80 iiissdo
81 iiisso
82 iiissio
83 iiissiio
84 iiissiiio
85 iiisdodddo
86 iiisdoddo
87 iiisdodo
88 iiisdoo
89 iiisdoio
90 iiisodddddsso
91 iiisodddddssio
92 iiisodddddddo
93 iiisoddddddo
94 iiisodddddo
95 iiisoddddo
96 iiisodddo
97 iiisoddo
98 iiisodo
99 iiisoo
100 iodoo
101 iodoio
102 iodoiio
103 iodoiiio
104 iodoiiso
105 iodoiisio
106 iodoiisiio
107 iiisiodddo
108 iiisioddo
109 iiisiodo
110 ioodo
111 iooo
112 iooio
113 iooiio
114 iooiso
115 iooisio
116 ioisso
117 ioissio
118 iooiisdo
119 iooiiso
120 ioioddo
121 ioiodo
122 ioioo
123 ioioio
124 ioioso
125 ioiosio
126 ioiosiio
127 ioiosiiio
128 ioioisdo
129 ioioiso
130 ioiioisso
131 ioiioddo
132 ioiiodo
133 ioiioo
134 ioiioio
135 ioiioiio
136 ioisiiso
137 ioiiosddo
138 ioiiosdo
139 ioiioso
140 ioisosso
141 ioisossio
142 ioisoddo
143 ioisodo
144 ioisoo
145 ioisoio
146 ioisoiio
147 ioisoiiio
148 ioisodsdo
149 ioisodso
150 iissdoiso
151 iissdoisio
152 ioisiodddo
153 ioisioddo
154 ioisiodo
155 ioisioo
156 ioisioio
157 ioisioiio
158 ioisioiiio
159 ioisioddso
160 iissoso
161 iissosio
162 iissosiio
163 ioiisdsdo
164 ioiisdso
165 ioisiiodo
166 ioisiioo
167 ioisiioio
168 ioisiioiio
169 iissdddso
170 iissiodso
171 iissiodsio
172 iissiodsiio
173 iissiodsiiio
174 iissiodsiiso
175 ioisiiioddo
176 ioisiiiodo
177 ioisiiioo
178 ioisiiioio
179 ioiissddo
180 ioiissdo
181 ioiisso
182 ioiissio
183 ioiissiio
184 ioiissiiio
185 ioiisdodddo
186 ioiisdoddo
187 ioiisdodo
188 ioiisdoo
189 ioiisdoio
190 iissiiiodddso
191 iissddsdddddo
192 iissddsddddo
193 iissddsdddo
194 iissddsddo
195 iissddsdo
196 iissddso
197 ioiisoddo
198 ioiisodo
199 ioiisoo
200 iioddoo
201 iioddoio
202 iioddoiio
203 iioddoiiio
204 iioddoiiso
205 iioddoiisio
206 iioddoiisiio
207 iioddoiisiiio
208 iioddoiiisdo
209 iioddoiiiso
210 iiododo
211 iiodoo
212 iiodoio
213 iiodoiio
214 iiodoiso
215 iiossdo
216 iiosso
217 iiossio
218 iiossiio
219 iiodoiiso
220 iiooddo
221 iioodo
222 iiooo
223 iiooio
224 iiooso
225 iioosio
226 iioosiio
227 iioosiiio
228 iiooisdo
229 iiooiso
230 iioioisso
231 iioioddo
232 iioiodo
233 iioioo
234 iioioio
235 iioioiio
236 iiosiiso
237 iioiosddo
238 iioiosdo
239 iioioso
240 iiososso
241 iiosossio
242 iiosoddo
243 iiosodo
244 iiosoo
245 iiosoio
246 iiosoiio
247 iiosoiiio
248 iiosodsdo
249 iiosodso
250 iiosiodsso
251 iiosiodssio
252 iiosiodddo
253 iiosioddo
254 iiosiodo
255 iiosioo

Welcome to Code Golf and nice first answer! Make sure to check out Tips for golfing in Prolog

JavaScript (E6) 141+3455=3596
Recursive function looking for the closest square root, but avoiding 16 as 16*16=256 will be changed to 0. Many other answer don't get this point.
F=(t,s='o',o='i')=>
  t>3?(
    q=Math.sqrt(t)|0,
    r=q+1,
    q-16?r-16||++r:--q,
    d=t-q*q,e=r*r-t,
    e<=d&&(o='d',d=e,++q),
    F(q,'s'+o.repeat(d)+s)
  ):o.repeat(t)+s

Test In FireFox/FireBug console
for(l=0,i=1;i<256;++i)o=F(i),l+=o.length,console.log(i,o),l

Output
1 io
2 iio
3 iiio
4 iiso
5 iisio
6 iisiio
7 iiisddo
8 iiisdo
9 iiiso
10 iiisio
11 iiisiio
12 iiisiiio
13 iissdddo
14 iissddo
15 iissdo
16 iisso
17 iissio
18 iissiio
19 iissiiio
20 iissiiiio
21 iisisddddo
22 iisisdddo
23 iisisddo
24 iisisdo
25 iisiso
26 iisisio
27 iisisiio
28 iisisiiio
29 iisisiiiio
30 iisisiiiiio
31 iisiisdddddo
32 iisiisddddo
33 iisiisdddo
34 iisiisddo
35 iisiisdo
36 iisiiso
37 iisiisio
38 iisiisiio
39 iisiisiiio
40 iisiisiiiio
41 iisiisiiiiio
42 iisiisiiiiiio
43 iiisddsddddddo
44 iiisddsdddddo
45 iiisddsddddo
46 iiisddsdddo
47 iiisddsddo
48 iiisddsdo
49 iiisddso
50 iiisddsio
51 iiisddsiio
52 iiisddsiiio
53 iiisddsiiiio
54 iiisddsiiiiio
55 iiisddsiiiiiio
56 iiisddsiiiiiiio
57 iiisdsdddddddo
58 iiisdsddddddo
59 iiisdsdddddo
60 iiisdsddddo
61 iiisdsdddo
62 iiisdsddo
63 iiisdsdo
64 iiisdso
65 iiisdsio
66 iiisdsiio
67 iiisdsiiio
68 iiisdsiiiio
69 iiisdsiiiiio
70 iiisdsiiiiiio
71 iiisdsiiiiiiio
72 iiisdsiiiiiiiio
73 iiissddddddddo
74 iiissdddddddo
75 iiissddddddo
76 iiissdddddo
77 iiissddddo
78 iiissdddo
79 iiissddo
80 iiissdo
81 iiisso
82 iiissio
83 iiissiio
84 iiissiiio
85 iiissiiiio
86 iiissiiiiio
87 iiissiiiiiio
88 iiissiiiiiiio
89 iiissiiiiiiiio
90 iiissiiiiiiiiio
91 iiisisdddddddddo
92 iiisisddddddddo
93 iiisisdddddddo
94 iiisisddddddo
95 iiisisdddddo
96 iiisisddddo
97 iiisisdddo
98 iiisisddo
99 iiisisdo
100 iiisiso
101 iiisisio
102 iiisisiio
103 iiisisiiio
104 iiisisiiiio
105 iiisisiiiiio
106 iiisisiiiiiio
107 iiisisiiiiiiio
108 iiisisiiiiiiiio
109 iiisisiiiiiiiiio
110 iiisisiiiiiiiiiio
111 iiisiisddddddddddo
112 iiisiisdddddddddo
113 iiisiisddddddddo
114 iiisiisdddddddo
115 iiisiisddddddo
116 iiisiisdddddo
117 iiisiisddddo
118 iiisiisdddo
119 iiisiisddo
120 iiisiisdo
121 iiisiiso
122 iiisiisio
123 iiisiisiio
124 iiisiisiiio
125 iiisiisiiiio
126 iiisiisiiiiio
127 iiisiisiiiiiio
128 iiisiisiiiiiiio
129 iiisiisiiiiiiiio
130 iiisiisiiiiiiiiio
131 iiisiisiiiiiiiiiio
132 iiisiisiiiiiiiiiiio
133 iiisiiisdddddddddddo
134 iiisiiisddddddddddo
135 iiisiiisdddddddddo
136 iiisiiisddddddddo
137 iiisiiisdddddddo
138 iiisiiisddddddo
139 iiisiiisdddddo
140 iiisiiisddddo
141 iiisiiisdddo
142 iiisiiisddo
143 iiisiiisdo
144 iiisiiiso
145 iiisiiisio
146 iiisiiisiio
147 iiisiiisiiio
148 iiisiiisiiiio
149 iiisiiisiiiiio
150 iiisiiisiiiiiio
151 iiisiiisiiiiiiio
152 iiisiiisiiiiiiiio
153 iiisiiisiiiiiiiiio
154 iiisiiisiiiiiiiiiio
155 iiisiiisiiiiiiiiiiio
156 iiisiiisiiiiiiiiiiiio
157 iissdddsddddddddddddo
158 iissdddsdddddddddddo
159 iissdddsddddddddddo
160 iissdddsdddddddddo
161 iissdddsddddddddo
162 iissdddsdddddddo
163 iissdddsddddddo
164 iissdddsdddddo
165 iissdddsddddo
166 iissdddsdddo
167 iissdddsddo
168 iissdddsdo
169 iissdddso
170 iissdddsio
171 iissdddsiio
172 iissdddsiiio
173 iissdddsiiiio
174 iissdddsiiiiio
175 iissdddsiiiiiio
176 iissdddsiiiiiiio
177 iissdddsiiiiiiiio
178 iissdddsiiiiiiiiio
179 iissdddsiiiiiiiiiio
180 iissdddsiiiiiiiiiiio
181 iissdddsiiiiiiiiiiiio
182 iissdddsiiiiiiiiiiiiio
183 iissddsdddddddddddddo
184 iissddsddddddddddddo
185 iissddsdddddddddddo
186 iissddsddddddddddo
187 iissddsdddddddddo
188 iissddsddddddddo
189 iissddsdddddddo
190 iissddsddddddo
191 iissddsdddddo
192 iissddsddddo
193 iissddsdddo
194 iissddsddo
195 iissddsdo
196 iissddso
197 iissddsio
198 iissddsiio
199 iissddsiiio
200 iissddsiiiio
201 iissddsiiiiio
202 iissddsiiiiiio
203 iissddsiiiiiiio
204 iissddsiiiiiiiio
205 iissddsiiiiiiiiio
206 iissddsiiiiiiiiiio
207 iissddsiiiiiiiiiiio
208 iissddsiiiiiiiiiiiio
209 iissddsiiiiiiiiiiiiio
210 iissddsiiiiiiiiiiiiiio
211 iissdsddddddddddddddo
212 iissdsdddddddddddddo
213 iissdsddddddddddddo
214 iissdsdddddddddddo
215 iissdsddddddddddo
216 iissdsdddddddddo
217 iissdsddddddddo
218 iissdsdddddddo
219 iissdsddddddo
220 iissdsdddddo
221 iissdsddddo
222 iissdsdddo
223 iissdsddo
224 iissdsdo
225 iissdso
226 iissdsio
227 iissdsiio
228 iissdsiiio
229 iissdsiiiio
230 iissdsiiiiio
231 iissdsiiiiiio
232 iissdsiiiiiiio
233 iissdsiiiiiiiio
234 iissdsiiiiiiiiio
235 iissdsiiiiiiiiiio
236 iissdsiiiiiiiiiiio
237 iissdsiiiiiiiiiiiio
238 iissdsiiiiiiiiiiiiio
239 iissdsiiiiiiiiiiiiiio
240 iissdsiiiiiiiiiiiiiiio
241 iissdsiiiiiiiiiiiiiiiio
242 iissdsiiiiiiiiiiiiiiiiio
243 iissdsiiiiiiiiiiiiiiiiiio
244 iissdsiiiiiiiiiiiiiiiiiiio
245 iissdsiiiiiiiiiiiiiiiiiiiio
246 iissdsiiiiiiiiiiiiiiiiiiiiio
247 iissdsiiiiiiiiiiiiiiiiiiiiiio
248 iissdsiiiiiiiiiiiiiiiiiiiiiiio
249 iissdsiiiiiiiiiiiiiiiiiiiiiiiio
250 iissdsiiiiiiiiiiiiiiiiiiiiiiiiio
251 iissdsiiiiiiiiiiiiiiiiiiiiiiiiiio
252 iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiio
253 iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiio
254 iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiiio
255 iissdsiiiiiiiiiiiiiiiiiiiiiiiiiiiiiio
3455

Picat, 242 code + 3455 output = 3697
See http://picat-lang.org/ for info about Picat.
import planner. final((N,N))=>true. action((N,A),B,M,C)?=>B=(N,A+1),M=i,C=1. action((N,A),B,M,C)?=>A!=16,A<N,B=(N,A*A),M=s,C=1. action((N,A),B,M,C)?=>A>0,B=(N,A-1),M=d,C=1. main([X])=>N=X.to_integer(),best_plan((N,0),P),printf("%w\n",P++[o]).

Less golf:
import planner.
final((N,N))=>true.
action((N,A),B,M,C)?=>B=(N,A+1),M=i,C=1.
action((N,A),B,M,C)?=>A!=16,A<N,B=(N,A*A),M=s,C=1.
action((N,A),B,M,C)?=>A>0,B=(N,A-1),M=d,C=1.
main([X])=>N=X.to_integer(),best_plan((N,0),P),printf("%w\n",P++[o]).

Python 3, 3455 + 182 bytes = 3637
from heapq import*
def f(x):
	q=[(0,0,"")]
	while 1:
		l,s,c=heappop(q)
		if s==x:return c+"o"
		for n,i in[(s+1,"i"),(s-1,"d"),(s*s,"s")]:
			if(n+1)*(n-256):heappush(q,(l+1,n,c+i))

Try it online!
This finds the optimal way to generate the number itself. It is not optimal if you allow partial outputting.

If this finds the optimal solution shouldn't it score 2036+codelength as the other optimal answers?

@Leo I'll edit mine. This is the optimum if you output the number by generating the number and appending o without printing partial results

APL: 80 + 3456 = 3536
⌽'o',{⍵<4:⍵⍴'i'⋄(b/'ids'),∇(-⊃b)+b[2]+⍵*÷1+3⊃b←(⍵>240)⌽⊃(>,<,=)/|⍵-2*⍨(⌈,⌊)⍵*.5}

Explanation: (corrected after edc65's note, thanks)
⍵<4:⍵⍴'i'  If argument is less than 3, replicate "i" that many times
(⌈,⌊)⍵*.5  ⍵ is the argument, take square root and take the ceiling and the floor
|⍵-2*⍨ elevate those ceiling and floor to power 2, remove argument, and make positive
b←⊃(>,<,=)/  get a boolean vector with a>b, a

(⍵>240)⌽  To avoid going to 256, do "i" for numbers over 240, instead of ^2
b/'ids' use that boolean to take either i, d or s and append it to the solution with ,
,∇(-⊃b)+b[2]+⍵*÷1+3⊃b Recursively call the function with argument -b1 +b[2] elevated to the power (inverse of b[3]+1)
Can count output with:
 +/⊃,/⍴¨(⌽'o',{⍵<4:⍵⍴'i'⋄(b/'ids'),∇(-⊃b)+b[2]+⍵*÷1+3⊃b←(⍵>240)⌽⊃(>,<,=)/|⍵-2*⍨(⌈,⌊)⍵*.5})¨¯1+⍳256

¨ applies the function to each number 0-255
+/⊃,/⍴¨ counts total number of elements
Again, you can try all of the above on TryApl.org
BTW: It's 3456 and not 3455 because I'm considering 0 too, as I think the problem was asking. If It's 1-255 then the score is 80+3455 = 3535

Invalid for many numbers (due to 256 and -1 -> 0). Example 255 iisssdo: i:1,i:2,s:4,s:16,s:256->0,d:-1->0,output 0

Didn't know about the 256->0.
I'll try again later.
Thanks for pointing that out.

APL . . . trolling ASCII peasants since

Python 3 – 4286 + 168 = 4454
Not a too serious one, but extremely simple. Just finds the best one of adding to 0, a square, a 4th power and an 8th power.
EDIT: Golfed 75 bytes, the 8th power did nothing
EDIT 2: Removed some bytes in order to correctly implement d. Score increased, though.
i=int(input())
s=round(i**.5)
q=round(s**.5)
o=round(q**.5)
a,b,c,d=i-256if i>127else i,i-s*s,i-q**4,i-o**8
print(sorted([(a*'i'if a>0else'd'*-a)+'o',s*'i'+'s'+(b*'i'if b>0else'd'*-b)+'o',q*'i'+'ss'+(c*'i'if c>0else'd'*-c)+'o',o*'i'+'sss'+(d*'i'if d>0else'd'*-d)+'o'],key=len)[0])

Python 3 – 2594 + 201 = 2795
This one uses a kind of depth-first search to find the shortest program. I added some (unnecessary?) optimizations to it, so I could get the result; this way it doesn't have to run that many paths. Might try to remove some of them. Doesn't beat the JS one as it uses smart tricks like multiple o's.
EDIT: Golfed off 93 bytes, I apparently had a crapton of useless code left there by development. Also removed everything I found unnecessary so far. Here I come, JS.
EDIT 2: Golfed off another 8 bytes. That return was unnecessary.
EDIT 3: Golfed an additional 5 bytes. Now that we got rid of that one wo could just put an elif instead of the other return.
EDIT 4: Corrected the functionality of d. Size increased by 1 byte, score by some bytes.
def f(i,s,h):
 global x,p
 if h==a:p+=[i]
 elif s<x[h]:x[h]=s;f(i+'s',s+1,h*h%256);f(i+'i',s+1,(h+1)%256);f(i+'d',s+1,max(h-1,0))
a,p=int(input()),[];x=[a]*256;f('',0,0);print(sorted(p,key=len)[0]+'o')

JavaScript (Node.js), 86 bytes, optimal output by brute-forcing
f=(n,a='',b=a,c,...s)=>n^b?f(n,...s,a+'i',b,-~c,a+'d',b,~-c,a+'s',b,c*c,a+'o',b+c,c):a

Try it online!

Python 2712 = 2608 + 104
Code:
v=lambda i:reduce(lambda x,y:(int(y),x[1]+['d','i'][int(y)>x[0]]*abs(int(y)-x[0])+"o"),str(i),(0,""))[1]

Use:
v(20)  -> 'iioddo'
v(250) -> 'iioiiiodddddo'

0-255 Code:
len(reduce(lambda x,y:x+v(y),range(256),"")) -> 2608

CJam, 2436 2392 2296 2173 (74 characters + 2099)
"叴噯撘桜᪍뾀戠냞霳㈨嵃畯㓱눿裸㺯蛙㡟激떍䑜㦘啟䂳嗳溘桠㼼ᗎ윆꘶英贈袄瞦㺣樅휏╴෼瓵ꃴ︥㷮싎ꗞ冺憳딕礕䀘䬴卺㽅鬞庘䲵"2G#b129b:c~

Which translates to:
r_(sa\a+{},\1/{{i_L\[_Tm3>{{__mqi:NN*-N)_*@-_@e<_@=_N+:N;'d'i?*+'s+N_Z3e>>}g}*T-_0<'d'i?\z*\2$3<'s*-W%'o]s\:Z:T;}%s0:T;3:Z;}:A~\A]_:,_$0=#=

Tries to optimize the Deadfish code length by choosing the shortest path to reach each digit of the number.
Thanks Martin for the Unicode translation
Here is the complete list of code
1:io
2:iio
3:iiio
4:iiso
5:iisio
6:iisiio
7:iiisddo
8:iiisdo
9:iiiso
10:iodo
11:ioo
12:ioio
13:ioiio
14:ioiiio
15:ioisio
16:ioisiio
17:ioiisddo
18:ioiisdo
19:ioiiso
20:iioddo
21:iiodo
22:iioo
23:iioio
24:iioiio
25:iioiiio
26:iiosiio
27:iioisddo
28:iioisdo
29:iioiso
30:iiiodddo
31:iiioddo
32:iiiodo
33:iiioo
34:iiioio
35:iiioiio
36:iiioiiio
37:iiiosddo
38:iiiosdo
39:iiioso
40:iisoddddo
41:iisodddo
42:iisoddo
43:iisodo
44:iisoo
45:iisoio
46:iisoiio
47:iisoiiio
48:iisodsdo
49:iisodso
50:iisiodddddo
51:iisioddddo
52:iisiodddo
53:iisioddo
54:iisiodo
55:iisioo
56:iisioio
57:iisioiio
58:iisioiiio
59:iisioddso
60:iisiioddddddo
61:iisiiodddddo
62:iisiioddddo
63:iisiiodddo
64:iisiioddo
65:iisiiodo
66:iisiioo
67:iisiioio
68:iisiioiio
69:iisiioiiio
70:iiisddodddddddo
71:iiisddoddddddo
72:iiisddodddddo
73:iiisddoddddo
74:iiisddodddo
75:iiisddoddo
76:iiisddodo
77:iiisddoo
78:iiisddoio
79:iiisddoiio
80:iiisdoddddddddo
81:iiisdodddddddo
82:iiisdoddddddo
83:iiisdodddddo
84:iiisdoddddo
85:iiisdodddo
86:iiisdoddo
87:iiisdodo
88:iiisdoo
89:iiisdoio
90:iiisodddddddddo
91:iiisoddddddddo
92:iiisodddddddo
93:iiisoddddddo
94:iiisodddddo
95:iiisoddddo
96:iiisodddo
97:iiisoddo
98:iiisodo
99:iiisoo
100:iodo
101:ioo
102:ioio
103:ioiio
104:ioiiio
105:ioisio
106:ioisiio
107:ioiisddo
108:ioiisdo
109:ioiiso
110:ioodo
111:iooo
112:iooio
113:iooiio
114:iooiiio
115:iooisio
116:ioisso
117:ioissio
118:iooiisdo
119:iooiiso
120:ioioddo
121:ioiodo
122:ioioo
123:ioioio
124:ioioiio
125:ioisiso
126:ioiosiio
127:ioioisddo
128:ioioisdo
129:ioioiso
130:ioiiodddo
131:ioiioddo
132:ioiiodo
133:ioiioo
134:ioiioio
135:ioiioiio
136:ioisiiso
137:ioiiosddo
138:ioiiosdo
139:ioiioso
140:ioiiioddddo
141:ioiiiodddo
142:ioiiioddo
143:ioiiiodo
144:ioiiioo
145:ioiiioio
146:ioiiioiio
147:ioiiioiiio
148:ioiiiodsdo
149:ioiiiodso
150:ioiisddsio
151:ioisioddddo
152:ioisiodddo
153:ioisioddo
154:ioisiodo
155:ioisioo
156:ioisioio
157:ioisioiio
158:ioisioiiio
159:ioisioddso
160:ioiisdsddddo
161:ioiisdsdddo
162:ioiisdsddo
163:ioiisdsdo
164:ioiisdso
165:ioisiiodo
166:ioisiioo
167:ioisiioio
168:ioisiioiio
169:ioisiioiiio
170:ioiisdsiiiiiio
171:ioiisddoddddddo
172:ioiisddodddddo
173:ioiisddoddddo
174:ioiisddodddo
175:ioiisddoddo
176:ioiisddodo
177:ioiisddoo
178:ioiisddoio
179:ioiissddo
180:ioiissdo
181:ioiisso
182:ioiissio
183:ioiissiio
184:ioiissiiio
185:ioiisdodddo
186:ioiisdoddo
187:ioiisdodo
188:ioiisdoo
189:ioiisdoio
190:ioiisodddddddddo
191:ioiisoddddddddo
192:ioiisodddddddo
193:ioiisoddddddo
194:ioiisodddddo
195:ioiisoddddo
196:ioiisodddo
197:ioiisoddo
198:ioiisodo
199:ioiisoo
200:iioddo
201:iiodo
202:iioo
203:iioio
204:iioiio
205:iioiiio
206:iiosiio
207:iioisddo
208:iioisdo
209:iioiso
210:iiododo
211:iiodoo
212:iiodoio
213:iiodoiio
214:iiossddo
215:iiossdo
216:iiosso
217:iiossio
218:iiossiio
219:iiodoiiso
220:iiooddo
221:iioodo
222:iiooo
223:iiooio
224:iiooiio
225:iiosiso
226:iioosiio
227:iiooisddo
228:iiooisdo
229:iiooiso
230:iioiodddo
231:iioioddo
232:iioiodo
233:iioioo
234:iioioio
235:iioioiio
236:iiosiiso
237:iioiosddo
238:iioiosdo
239:iioioso
240:iioiioddddo
241:iioiiodddo
242:iioiioddo
243:iioiiodo
244:iioiioo
245:iioiioio
246:iioiioiio
247:iioiioiiio
248:iioiiodsdo
249:iioiiodso
250:iioisddsio
251:iioisddsiio
252:iioiiiodddo
253:iioiiioddo
254:iioiiiodo
255:iioiiioo

Try it online here:

For whatever it's worth, your solutions appear optimal except for 1 and 2 - io and iio would be shorter.

You appear to have gotten the effect of the d operation wrong - if it decrements to -1, it gets reset to 0, not 255.

Invalid for many numbers (due to 256 and -1 -> 0). Example 255 iisssdo: i:1,i:2,s:4,s:16,s:256->0,d:-1->0,output 0

Now, about the o command writing a newline ...

@edc65 I checked the wiki page. I did not find anywhere that o prints newline. All compilers also were simply printing without new line.

The language spec is nearly not-existing so anything goes. But looking at the compilers code... C printf("%d\n",x); C# Console.WriteLine(x) GO fmt.Println(x) pascal WRITELN(val); python print accumulator (no comma) bash echo $no;; (no -n)

I think we need OP to clearly state this in the question then.

With 103 characters in the source you can shorten this with Unicode packing.

Here is one way to do it, 59 characters: http://pastebin.com/u5Pzh8Xb

some of the codes are "interesting" choices. for example, in your code for 167 it uses dddsdd to move from 6 to 7 instead of i.

@proudhaskeller Should be fixed now.

There is a bug in your program. All the codes 100-109 200-209 seem to ignore the 0

authors: Ростислав Олегович

authors: محمد الفاروق

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Jumblers vs Rebuilders: Coding with Tetris Bricks
In traditional Tetris, there are 7 distinct tetromino bricks, each denoted by a letter similar to its shape.
#
#      #    #
#  ##  #    #  ###  ##    ##
#  ##  ##  ##   #    ##  ##
I  O   L   J    T    Z    S

Consider the arrangements of these bricks that can make a solid W×H rectangle, for some positive integers W and H. For example, using 2 I's, 1 L, 1 J, 2 T's, and 1 S, a 7×4 rectangle can be made:
IIIITTT
LIIIITJ
LTTTSSJ
LLTSSJJ

The same bricks can be rearranged (by moving and rotating but not flipping) into a different 7×4 pattern:
IJJTLLI
IJTTTLI
IJSSTLI
ISSTTTI

Now consider using a rectangular block of code in place of the first arrangement. For example this 7×4 bit of Python 3, which prints Tetris to stdout:
p=print
x='Tet'
y='ris'
p(x+y)#

According to the first Tetris arrangement its 7 "bricks" are...
           x          '
      int  y          '  ='r   is
p=pr   t   p(  ='Te  )#   x   +y

In the other arrangement (one of many possible) they are unintelligible as code:
r#)x(x=
p'r'=y'
='istpT
p+ytnie

But, given the bricks separately, it might be possible to piece them back together properly. This is the basis of the challenge.
Challenge
This is a cops-and-robbers challenge. There are two competing roles, the Jumblers and the Rebuilders.
The Jumblers submit answers with blocks of code that have been broken down into Tetris bricks.
The Rebuilders attempt to rebuild these blocks in the separate question dedicated for them: Jumblers vs Rebuilders: Coding with Tetris Bricks - Area for Rebuilder Answers.
Jumblers
Using only printable ASCII (hex codes 20 to 7E) write a W×H rectangular program. When run, it must output the sole word Tetris to stdout (or closest alternative). Do not post this code in your answer; don't give W or H either. Break it up into some arrangement of Tetris bricks like the example above and post these in your answer. (Your code may contain spaces but since they are hard to distinguish, it's best to use some other character in place of spaces and tell people what you used.)
The harder it is to rebuild your program the better. There may be many ways to rearrange your code-bricks into a rectangle, possibly with different dimensions. What the code does when run in these different arrangements doesn't matter as long as at least one arrangement prints Tetris to stdout.
The only other restriction is that W * H be less than 1025.
Jumblers should specify their programming language (and version).
Rebuilders
Your goal is to take a Jumbler's code-bricks and put them back into their original order, so Tetris is printed when the code is run. If the working arrangement you find isn't the one the Jumbler had in mind that's too bad for them.
Remember that only translation and rotation are allowed in rearrangements, not mirroring.
Scoring
Each time a submission is rebuilt it is considered "cracked" and is no longer in the running. The first Rebuilder to rebuild a submission gets the credit for it. If an answer goes uncracked for 72 hours the Jumbler should reveal the solution and will be henceforth immune from being cracked. A Jumbler must do this to win, since otherwise it will be unclear if there even was a solution.
The winning Jumbler is the uncracked answer with the smallest area (W * H = 4 * num of bricks). In case of ties the highest voted answer wins. The accepted answer for this question will be the winning Jumbler.
The winning Rebuilder is the user who cracks the most submissions. In case of ties it goes to whomever cracked the most cumulative area.
Notes

You may not rebuild your own submissions. (But otherwise you may take on both roles.)
Rebuilders may not attempt to crack the same answer more than once.

Scoreboard
Sorted from oldest submission to newest.
+--------------+-------------+------------------+---------+----------+----------------+-------------------------------------------+-------------------------------------------+
|   Jumbler    |  Language   |       Area       | Immune? | Rebuilt? |   Rebuilder    |                      Link                 |                  Solution Link            |
+--------------+-------------+------------------+---------+----------+----------------+-------------------------------------------+-------------------------------------------+
| xnor         | Python 3    | 212              | no      | yes      | foobar         | https://codegolf.stackexchange.com/a/40142 | https://codegolf.stackexchange.com/a/40203 |
| xnor         | Python 3    | 340              | no      | yes      | feersum        | https://codegolf.stackexchange.com/a/40146 | https://codegolf.stackexchange.com/a/40189 |
| es1024       | C           | 80               | no      | yes      | user23013      | https://codegolf.stackexchange.com/a/40155 | https://codegolf.stackexchange.com/a/40210 |
| Ethiraric    | Brainfuck   | 108              | yes     |          |                | https://codegolf.stackexchange.com/a/40156 |                                           |
| Qwertiy      | JavaScript  | 420              | yes     |          |                | https://codegolf.stackexchange.com/a/40161 |                                           |
| user23013    | Befunge     | 360              | yes     |          |                | https://codegolf.stackexchange.com/a/40163 |                                           |
| user23013    | CJam        | 80               | yes     |          |                | https://codegolf.stackexchange.com/a/40171 |                                           |
| Geobits      | Java        | 360              | yes     |          |                | https://codegolf.stackexchange.com/a/40180 |                                           |
| Dennis       | CJam        | 60               | yes     |          |                | https://codegolf.stackexchange.com/a/40184 |                                           |
| xnor         | Python 3    | 160              | yes     |          |                | https://codegolf.stackexchange.com/a/40192 |                                           |
| COTO         | C           | 72               | yes     |          |                | https://codegolf.stackexchange.com/a/40198 |                                           |
| es1024       | C           | 780              | yes     |          |                | https://codegolf.stackexchange.com/a/40202 |                                           |
| Gerli        | Mathematica | 72               | no      | yes      | Martin Büttner | https://codegolf.stackexchange.com/a/40230 | https://codegolf.stackexchange.com/a/40242 |
| Hydrothermal | JavaScript  | 80               | yes     |          |                | https://codegolf.stackexchange.com/a/40235 |                                           |
| Sam Yonnou   | GolfScript  | 48 (frontrunner) | yes     |          |                | https://codegolf.stackexchange.com/a/40239 |                                           |
| feersum      | Matlab      | 48               |         |          |                | https://codegolf.stackexchange.com/a/40310 |                                           |
| Beta Decay   | Python 3    | 484              |         |          |                | https://codegolf.stackexchange.com/a/40312 |                                           |
| potato       | Python 3    | 176              |         |          |                | https://codegolf.stackexchange.com/a/40341 |                                           |
+--------------+-------------+------------------+---------+----------+----------------+-------------------------------------------+-------------------------------------------+

(Thanks to http://www.sensefulsolutions.com/2010/10/format-text-as-table.html for table formatting.)
User COTO made an excellent tool for playing with code-bricks. I've turned it into a convenient snippet:

Put code-bricks here and hit OK. Re-run the snippet to restart.
(You may need to replace spaces in code-bricks with some other character first.)
<textarea id='spec' rows='16' cols='80'>ABCD  a
      b   Oo
      c   oo
      d

 E    h
 F  efg   hg   GFE
 GH        f   H
           e

 I           IJK
 J   l         L
LK   kji  kl
          j
          i
                   t
 OP   p     QR    rs
MN    on     ST   q
       m
 W             z
 XY    zxw    yx     Y
 Z      y      w    WXZ</textarea>
<button id='go' type='button' onclick='go()'>OK</button>

@11	@22	@33	@44

@11

@22

@33

@44

@40	@30	@20	@10

@40

@30

@20

@10

	@11

	@22

@33	@44

@31

@42	@23	@14

@41	@32

@23

@14

@11	@22	@43

		@34

@11	@22

@33	@44

@30	@10

@40	@20

@40	@30

@20	@10

@20	@40

@10	@30

@11

@22

@33	@44

@31	@22	@13

@44

@41	@32

	@23

	@14

		@41

@12	@23	@34

	@21	@12

@43	@34

@41

@32	@23

	@14

	@30	@40

@10	@20

@10

@20	@30

	@40

@11	@22

	@33	@44

	@11

@32	@23

@44

@40	@30

	@20	@10

	@40

@20	@30

@10

@11	@22	@33

	@44

	@11

@42	@23

	@34

	@41

@32	@23	@14

@31

@22	@43

@14

Sounds like a job for Befunge.

Would OP please tell us how he manages to come up with stuff like this?

@SohamChowdhury I can't say much more than I've already said. My main tenets are simplicity and originality.

Can I still submit a problem, or is this challenge closed to Jumblers?

@ASCIIThenANSI Go ahead. Not many rebuilders are still around though.

So this is the challenge which is breaking my parser regexes...there's something in here that freezes everything up.

GolfScript 48
I pieces:
!;..  )+?;

O pieces:
.[  ;*  .(
):  ++  -\

T pieces:
+]\  +++  ;).  );.
 .    *    ,    )

J pieces:
.    )    *
(@@  :?,  .,:

Solution

 .[!)):,.
):;+:?,*
;*.?;).+
++.;),*+
.(..;).+
-\(@@\]+

Yeah oops I was using it to come up with the tetris pieces. I edited it quickly enough that the "edited" link shouldn't show up so people shouldn't be able to look at the edit history for the answer.

Well I don't want to spoil the game, but let's hope I was the only one who opened the page that quickly. ;)

I know this is long overdue but I'm officially ending the contest, and unless I'm mistaken this submission won! Sam, I'll accept this answer if you post the solution to prove that it was in fact possible.

@Calvin'sHobbies Done

Java : 360 area

Bounty: 500
Reconstructing these things is hard! That's probably why there aren't too many robbers participating in this challenge. However, I want to see mine cracked. So, instead of giving the solution after 72 hours, I'm putting up 500 rep to the first successful cracker. To clarify, I will add a +500 bounty to the answer post and award it to your crack if you reassemble these pieces into any working, rectangular Java program that outputs "Tetris". I am not preemptively activating the bounty, because I don't feel like wasting rep if nobody answers.
There is no end date to this offer. It's valid as long as I'm a member here. To ensure I see your answer, ping me with a comment below.
I've triple-checked to make sure the pieces (and code) are valid, but if a trusted user wants to confirm this, I can email/something the solution to them. Obviously, that would exempt them from posting it and collecting the bounty.

Made of a mix of all seven piece types. To make things easier(?) I've made sure that all pieces of the same type are rotated to the same orientation. Since Java has parts that can't be changed much, I've left the really obvious parts as simple I-blocks to get it started.
Note: Since Java has a few mandatory spaces, I've replaced them with underscores (_)below for layout purposes. There are 11 of them total, and they should all be converted to spaces to run the code. No other whitespace is present in the code, any below is just for positioning.
There are:

41 I
15 O
11 J
8  L
6 T
6 S
3 Z

Have fun!
------------- I

clas    s_X{    publ    ic_s

tati    c_vo    id_m    ain(

Stri    ng[]    2;c*    p(b-

(b-c    _voi    nt_a    Syst

em.o    ut.p    rint    1,c=

d=1,    e=3,    new_    int[

;b++    for(    1008    ?1:2

)a);    ccc+    ==++    pf}(

for(    (b);    p(b+    --b-

or(d    1?1:    +1;e    for(

=1);

------------- O

a)
*2

b=
r(

12
<3

36
[c

*1
++

b<
6]

64
64

7]
]-

<1
1;

89
0;

;p
c)

=0
ic

st
ch

at
ar

d/
1;

-------------- T

{in
 ]

+b(
 5

d/2
 ;

d<<
 )

;;;
 1

=1)
 (

------------- L

2=[
+

]b*
8

=1)
]

<<b
<

}_}
d

3=b
)

+[[
=

=c,
=

-------------- J

o
;b=

,
2;)

f
2;c

*
=][

c
f=d

+
e1+

e
=;;

d
_p(

i
<++

=
){_

[
f+e

---------------- S

 t_
;f

 c+
1)

 +<
;p

 64
<6

 b=
;p

 ))
(;

--------------- Z

4,
 -1

;=
 ff

;f
 0;

Do any of the code blocks have to be rotated to construct a valid (or at least, the intended) solution?

@El'endiaStarman Yes, you'll need to rotate some for the intended solution.

Brainfuck, 108 area
This code was made of 27 I pieces.
-.[>
.<++
.<++
[>++
[>++
-]++
]>.-
-]>[
-]>+
]>++
+.+-
+[>+
+-+-
++[>
++[>
++]-
++++
++++
+++<
+++<
+<-]
--<-
<-]>
<><+
>+.>
>++[
>+<<

I don't know if there is any way other than bruteforce to find the answer. If there is, i'd really like to know how.

Python 3: 212 area [Rebuilt]
My code is broken up into the following 53 I-pieces, which I've written one per line alphabetically.
(358
0048
0396
0796
0824
0981
1013
1314
1330
1438
1502
2285
2317
2479
2585
2955
3116
3738
3818
4169
4356
4360
4632
4800
5016
5153
5256
5394
5598
5631
5758
5840
6312
6425
6539
7045
7156
7163
7329
7624
7674
8164
8250
8903
9%38
9009
94))
9413
9748
etri
prin
s'*
t('T

Have fun!

I found a vulnerability in this method, but I'll leave it to be cracked. I've posted another answer that I hope is more secure.

print('Tetris'* (3580048039607960824098110131314133014381502228523172479258529553116373838184169435643604632480050165153525653945598563157585840631264256539704571638903974876749009825073297156762481649%38941394))

@foobar Congrats! Did you try lots of shuffles mod 38941394 or something more systematic? How long did it take? Also, why not %3894?

I just pre-built print('Tetris'* (358UNKNOWN94)) and as I was pretty sure that you didn't rotate any tiles, all I did was to build all possible permutations of the remaining tiles, joined them together and evaluated if 358UNKNOWN94 is equal to 1, while i replaced UNKNOWN with the permutation. So I didn't use %3894 because a different matching permutation was found first ;) I don't know how long it took exactly, but it was about 20 minutes using a single core. So I actually used something less systematic, I just bruteforced the solution ;)

I see now why %3894 can't work. Since 3894 is a multiple of 3, taking mod 3894 preserves value mod 3. But, rearranging also digits preserves value mod 3, since it equals that of the digit sum. So, there's no way to get around the remaining digits not summing to 1 mod 3.

Now that it's cracked, I would be interested in the vulnerability you've found unless there's a chance, that it could also be applied to your second post.

I see. My values were different and more evenly balanced in length. The vulnerability was simply that a%b=1 is not that unlikely to happen when b is small, so trying random a's or a brute-force like you did would work. I tried to prevent that in my second attempt. Good luck!

@Calvin's Hobbies with your edit that the solution must be pasted as the rectangle, not a single line, the solution is still a rectangle with the width being 212 and the height being 1. It's also the only solution, as there are 53 tiles of the same type and 53 is a prime. So the only two possible rectangles would be 2121 and 453. Making it a 4*53 rectangle results in invalid syntax. This is because print and other tokens that exceed a length of four would have to be split over several lines, which is illegal.

I just posted the previous comment in case you made the edit to your question due to my answer to this post.

@foobar Your answer made me think of it but it's definitely still valid. I just felt I should clarify.

@MartinBüttner done ;) http://codegolf.stackexchange.com/a/40203/19475

Javascript, area 420
Only I-blocks.
!!!(
!!!+
!!!+
!!![
!!!]
!!!]
!!!]
!!!]
!!!]
!!'!
!![]
!!]]
!(!+
!(![
!+!]
!+!]
!+"+
!++)
!++[
!++[
!++[
!++[
!++]
![+[
!](+
(!!'
(!!+
(!(]
(++!
(['[
)!'!
)[)[
)]]!
+++"
+++)
++++
+++[
+++]
++])
+[+[
+[[[
+]'+
+]']
+]+[
+]+[
+]]!
+]]!
+]]!
+]]!
+]]'
+]][
+]]]
[!!+
[!!+
[!!+
[!!+
[!!+
[!!]
[!+!
[![[
[![[
[((!
[))!
[){!
[+'+
[++)
[++]
[[)+
[[+[
[[[!
[[['
[[[+
[][]
[]]]
[{[[
]!(!
]!]+
]['[
][[!
][[!
][[!
][[!
][[(
][[+
][[+
][[[
][[[
][]]
][}!
]]T]
]][(
]]]!
]]]!
]]]'
]]])
]]]]
]}]]
a['!
e]'(
l++[
v).!
{[[[
{]g]
})')
}]]]
No any standard obfuscators were used. All code including obfuscation and making this sorted list of blocks is made by less then 16 lines of my own code.

It's time to show how it was made:
x="+[],+!![],+!![]+!![],+!![]+!![]+!![],+!![]+!![]+!![]+!![],+!![]+!![]+!![]+!![]+!![],+!![]+!![]+!![]+!![]+!![]+!![],+!![]+!![]+!![]+!![]+!![]+!![]+!![],+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![],+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]".split(/,/g)
res={}
for(q=0; q<x.length; ++q) res[eval(x[q])]=x[q]
function add(str) { for(q=0;q<Math.min(str.length,10);++q) res[eval(x=str+"["+res[q]+"]")]=x }
add("({}+[])")
add("(![]+[])")
add("(!![]+[])")
add("([][[]]+[])")
code = 'eval('+Array.prototype.map.call('console.log("Tetris")',function(x){return res[x]||"'"+x+"'"}).join("+")+')'
res=[]
console.log(code)
code.replace(/(.)(?=.{104}(.).{104}(.).{104}(.))/g,function(m,a,b,c,d){res.push(a+b+c+d)})
eval(res.map(function(x){return x[0]}).join("")+res.map(function(x){return x[1]}).join("")+res.map(function(x){return x[2]}).join("")+res.map(function(x){return x[3]}).join(""))
console.log(res.sort().join("\n"))

So, it's just call to eval with obfuscated 'console.log("Tetris")' argument, which is 420 symbols in length. It is splitted into 4 lines of 105 symbols and read by columns and alphabetical sorted.
Obfuscation for 10 digits is hardcoded, for other symbols used first 10 symbols from 4 combinations passed to add function. If there is no obfuscation for some symbol it is passed as is.

Is it time to post how it was done?

@Qwerity Yes, if you want.

Explanation is added.

JavaScript - Area 80
Seems like a lot of these answers are just using lots of I pieces and maybe an O piece or two, so I threw this together with some of the more interesting shapes.

7 I pieces
1 L piece
1 J piece
4 O pieces
6 T pieces
1 S piece

Each piece is separated by two spaces. The two hash signs are actually spaces in the code.
l  n  \  /  ;  +  r
o  -  x  c  v  (  i
g  (  5  o  a  ;  s    )  o    //  #c  ns  ->   )    "    d    l    e    l    wi
(  "  4  n  r  ;  "  x65  log  ;/  ")  ].  "c  "(#  o+\  ave  ow"  t"o  "Te  ["

Have fun!

C, 80 area
Made of 12 I pieces and 8 O pieces. C syntax is always fun.
I pieces in no particular order:
 c[] // starts with a space
','n
',;}
(q){
,',  // ends in a space
u>6/
T2sr
char
main
q/**
t#1'
ts(c

O pieces:
q<
pu

't
i'

Ir
$'

/}
);

'?
re

',
`:

"e
i>

={
,0

main(q){char c[] ={'/T','$"e','t' ,0162,'rIi>`:i', '?#>s',q<q/**/}; return puts(c);}

@user23013 Congratulations!

Befunge, 360 area
90 O-pieces.
 "
#6

 "
#^

 #
#

 #
4

 +
$

 +
0>

 +
v_

 0
>

 3
#

 >
\

 ^
/1

 _
v8

 v
$,

 ~
*=

!!
00

!<
v>

"!
<

"<
#^

">
^<

"v
#

"v
w\

#
 #

#
|_

#*
_*

#0
.@

#3
~#

#?
t@

#^
RI

#v
~>

#~
~#

$
!4

&v
v#

*#
"#

**
>^

+1
>^

+5
 ,

+^
S"

-
#"

-#
2\

-~
 #

0
|>

00
00

0<
v\

2,
+#

2v
^v

3#
<

3#
>2

3~
^-

47
31

6
6#

70
"T

8#
:\

:#
 #

:$
$*

:0
3<

<
#$

<*
<|

<<
>>

<>
<>

<@
 >

<~
2,

>
7<

>$
^6

>>
<<

>v
|g

\
^

\_
 !

^
<s

_!
>9

_$
ET

kr
 >

m~
#3

q~
~+

r^
c

t~
,

v
 ?

v/
_$

v4
>>

v7
>#

v<
>#

v<
>#

v>
:^

v~
1/

zr
 $

~#
#~

~#
\#

~$
7>

~3
$_

~v
\$

~~
~#

You can try it here.

3#~#~vm~00-~q~\_:$:#r^&v_!!<v<
>2\#\$#300 #~+ !$* #c v#>9v>>#
"v0< 36 v < ~~ ^<~^ <<<@\ -##v
w\v\# 6# ?#$~#/12,<s>> >^ 2\~>
"> +>$ +:0 _ #2,v/$ >>v4v7- 3~
^<0>^6v_3<v84 +#_$!4<<>>>##"^-
<*8#> #0 v ~v~2v#~~#kr"v "zr"<
<|:\7<.@$,*=1/^v~##~ ># #6 $#^
#*+1# 3# 0470 >vv< ## ~$t~ "<>
_*>^|_< > 31|>|g>##  #7>, #^<>
70_$#^+^~3 +** >v>!!+5#3*#"!#?
"TETRIS"$_$ >^\ :^00 ,~#"#< t@

 There are probably other solutions. I didn't rotate the bricks.

This is one of the most convoluted Befunge programs I have ever seen and watched run. Very clever!

CJam, 60 (15 O's)
71 05 37 23 36 04 27 69 32 :i 12 93 bi i] 43
69 44 71 71 -# 70 10 25 44 cb 93 20 *G 9B 62

Solution

27
10
96
17
54
04
52
96
71
37
12
93
43
62
29
03
07
40
44
23
72
13
]B
i9
*b
Gi
6#
3-
ib
:c

Python 3: 340 area [Rebuilt]
Made of 85 I-pieces, given here alphabetized one per line.
    #Four spaces
    #Four spaces
    #Four spaces
    #Four spaces
    #Four spaces
    #Four spaces
    #Four spaces
    #Four spaces
    #Four spaces
))  #Two spaces
0290
0398
0866
0887
0892
0992
1108
1268
1297
1339
1555
1722
1817
1848
1930
2328
2521
2611
2747
3179
3192
3245
3284
3334
3613
3862
4086
4629
4639
4674
4695
4781
4968
5723
5742
5791
5938
6011
6069
6180
6231
6265
6269
6444
6564
6776
6884
7116
7253
7348
7440
7527
7743
7873
8064
8291
8808
8843
9305
9324
9458
9460
9586
9869
====
a,b,
abcd
c)-d
etri
pow(
prin
s'*(
t('T

As a Python list:
['    ', '    ', '    ', '    ', '    ', '    ', '    ', '    ', '    ', '    ', '    ', '))  ', '0290', '0398', '0866', '0887', '0892', '0992', '1108', '1268', '1297', '1339', '1555', '1722', '1817', '1848', '1930', '2328', '2521', '2611', '2747', '3179', '3192', '3245', '3284', '3334', '3613', '3862', '4086', '4629', '4639', '4674', '4695', '4781', '4968', '5723', '5742', '5791', '5938', '6011', '6069', '6180', '6231', '6265', '6269', '6444', '6564', '6776', '6884', '7116', '7253', '7348', '7440', '7527', '7743', '7873', '8064', '8291', '8808', '8843', '9305', '9324', '9458', '9460', '9586', '9869', '====', 'a,b,', 'abcd', 'c)-d', 'etri', 'pow(', 'prin', "s'*(", "t('T"]

I made a mistake and pasted too much. I've fixed it now, but rebuilders, please don't look through the edit history.

FYI, you fixed it within the grace period, so there's no edit history to worry about.

The main list is missing two of the 4-space blocks.

@feersum Congrats! I totally didn't think of using overhangs like that. Time to make a new and better jumble.

Cracked btw.

Python 3: 160 area
After feersum's crack, I tried to tighten up my code to make it harder to avoid cryptographic mumbo-jumbo. It's made of 40 I pieces, listed one per row:
')    #Two spaces
)-d)
*'Te
,b,c
0484
0824
2448
2562
3094
3762
3896
4052
4233
4562
5266
5277
5400
5885
5927
5965
6080
6720
6808
6884
7568
7856
7963
8609
8639
8665
8732
8892
9206
9893
====
abcd
ow(a
prin
t((p
tris

As a Python list:
["')  ", ')-d)', "*'Te", ',b,c', '0484', '0824', '2448', '2562', '3094', '3762', '3896', '4052', '4233', '4562', '5266', '5277', '5400', '5885', '5927', '5965', '6080', '6720', '6808', '6884', '7568', '7856', '7963', '8609', '8639', '8665', '8732', '8892', '9206', '9893', '====', 'abcd', 'ow(a', 'prin', 't((p', 'tris']

Changed:

Reordered string multiplication to try to force pow to be used
Fewer spaces (though shorter numbers)
No 1's

I am worried about the many factors of the area though.

CJam, 80 area
20 O-pieces.
 I
`7

&d
'X

+5
7m

-2
`-

-6
#b

-O
U[

3Z
Pi

4"
2X

43
P"

?<
5b

D:
.=

FH
uL

K`
~C

QT
:c

[^
+9

aj
^F

hD
dP

tn
6

uq
KG

x6
CF

 -24"hD&d ID:uqx6tn-OajFH43[^+5?<3ZK`-6QT
 `-2XdP'X`7.=KGCF6 U[^FuLP"+97m5bPi~C#b:c

 I didn't rotate the bricks.

C - Area 72
Blocks:
I    J     _______ L ______       O      __ Z _     _______ T ______
          /                \   /    \   /      \   /                \
"    e    m   "   T   )   6    };  ii   3"   (.    \nn  {6"  ]"0  i%s
i    t    p   ,   &   m   1    -]  ar    "\   f(    t    8    e    T
s   )"    .[  0x  ,f  ai  0r
"

 ""   (t   ["
)"   61   4+
\____   ____/
      S

Since the only other C submission was cracked. ;)
A neat 72 characters. Pure obfuscation. No NP-hard problems to solve or huge integers to factor. Borrows some tricks from one of the greats. Spaces are represented using .s. No actual .s appear in the solution.
I've triple-checked the solution to ensure validity of the pieces.

C - Area 780
There are 195 pieces in total. No comments were used. Nothing particularly complicated.
Note: all backslashes (\) are to be replaced with spaces.
95 I Pieces:
____ x12
incl
\edu
\\\\
\\\\
\\\\
dts<
h.oi
*_*>
_,_(
int\
__;\
,_(_
_*_,
=__,
__"*
+|_;
r__+
ahct
)=pu
_\ra
f\ch
edep
#t_,
y___
*_;_
(_;-
){__
,<_\
9"=_
+__*
___;
_+>_
_??<
+__*
*__,
__*_
*=+_
__:-
___-
_+__
,___
,__,
_,*&
*\&*
_,*_
_++,
+,__
++++
+__=
_++,
,,,_
___+
=+__
?++_
___+
=__+
,<_*
__+*
&+;*
+*__
__*_
__+,
++?~
__-9
_?__
__*_
(_+_
[**(
_<&_
};__
_@A:
(nia
@@@@
AAAA
AAAA
~~~~
_++;
_&,)
A__+
~~__
g_""
_;}_
+*__

35 O Pieces:
__
__
 (x18)
)_
__

_*
_\

_;
,-

_*
__

~)
"{

+_
+_

*_
,_

__
_)

~~
a~

_,
__

__
,)

_:
__

+*
__

__
+,

*+
_+

AA
AA

__
,+

18 L Pieces:
___
_
 (x2)
_;*
_
_=_
+
__*
_
+__
_
**_
&
+*_
_
&*&
,
++,
_
_*_
_
;;_
"
__+
_
AAA
~
"*)
;
___
(
,_-
_
_~^
_

25 J Pieces:
_+=
  +
+,_
  _
*__
  ;
;;_
  \
_,_
  )
~~~
  _
___
  A
~;(
  _
;__
  i
_;m
  A
=__
  _
a;a
  A
="A
  a
~_\
  o
o_a
  a
~~~
  _
99-
  _
*9_
  _
__)
  _
__*
  <
+_,
  _
_++
  =
_+_
  _
++_
  _
_+:
  _

10 T Pieces:
 _
,__
 +
*?_
 =
**=
 _
__+
 _
:_+
 _
_+_
 _
(_-
 +
++,
 +
___
 *
__:

4 Z Pieces:
=*
 ++
*+
 __
t_
 -~
__
 f(

8 S Pieces:
 _,
_,
 __
__
 (x2)
 -_
__
 (x2)
 _9
~_
 99
__
 __
],

Solution

#include             <stdio.h>
typedef char _________; int (*
_____)()=putchar;____(_,___,__
,______) _________*__,* *___,*
______;{__="9>?_|";______=*___
;--_;--_<*__++?++*______,_+=_+
_:___,__,___;_<*__++?*______+=
*______,++______,__,*______+=*
______,__,++______,*&*______+=
*______,++______,* &*______+=*
______,++______,*&*&*______+=*
______,++______,_,*______+=*&*
______,_+=_+_:__,_;_<*__++?++*
______++,++*______++,++*______
++,++*______++,++*&*______++,_
,++*______,_+=_+_+_+_:______;_
<*__++?~_____(_-_+_-_)^~_____(
*______),++*___,_____,_,_+=*&*
______,_+_:_____(_+_-_-_);;_<*
__?--*______:___;}_________ _[
999-99-99],*__=_;main(______){
_________*___="AAA@@@@@~~~~~~"
"~~~~~~aAAAAAaAAAAAAAAAAAAA;;"
"aa~~~~~~~~~a;a";_____:____((*
___-______),&__);if(__,*++___)
goto _____;++______;++______;}

Wolfram, area 72
Everywhere you see a dash (-), replace it with a space
i
h01-

r*1/

j
6
115

l
  m
+1C

  t
*0e

  e
,,[

o
r4
a+

s
 10
-1

 +1
Pr

z
ro
 8*

ac
 -1

od
 +1

t
--F
 {

,50
 0

/]}  -- fixed bracket directions
 0

1-,
 ,

01C
 0

tni
 4

Do you mean Wolfram language (i.e. Mathematica)? All your brackets and braces point in the same direction - did you accidentally flip them around when rotating the blocks?

Okay yes, the bracket and brace in third T block should be the other way round. I managed to rebuild it.

Wolfram language, yes. Oh no, I did make a mistake! Congratulations for solving it despite that!

I fixed the T. I printed out the code and rotated the paper to reduce mental exercise... I forgot to take into account the fact that the symbols changed as well...

MATLAB, area 48
Unfortunately, it does not seem to work in Octave.
-
^-1

'
'u"

v'+
e

[['
;

'.i
]

lmi
a

 kv
hW

 .x
).

3)
t;

b(
'p

('l;

.]'e

Python 3
Area - 484
Spaces replaced by %. There are some comments used as padding. Quite a bit of repetition of code. May be quite complicated.
121 Os
41
)+

%r
1-

:#
1#

%r
1-

01
,+

a1
n+

))
0+

h1
r-

#0
##

--
ge

11
1-

hr
1-

--
-1

ap
0+

+1
+'

h0
r+

:1
##

11
1-

))
0+

a0
p+

n0
d+

f%
oz

-1
0+

hr
1-

n0
d+

a0
p+

a1
n+

+0
1+

hf
.=

i1
%-

f%
oa

a1
n+

(c
0+

(0
1+

0,
1+

i1
n+

in
1+

r+
%=

-0
1+

fo
%l

n'
d'

--
=1

p1
%-

-;
-a

-;
-h

a1
n+

pe
0+

pe
0+

-1
0+

n0
d+

11
0-

a0
p+

i1
n+

hz
.=

n0
d+

##
)#

5)
1+

g(
1-

%1
r-

(c
.j

(0
c+

11
0-

(z
n(

g(
1-

41
)+

)s
)'

in
1+

r+
%=

ap
in

g(
1-

01
,+

-a
-n

(l
1+

pt
e(

%1
r-

-#
]#

(1
f+

g1
(-

h.
l=

01
,+

h.
pr

:1
##

:#
1#

(1
z+

r+
%=

+1
0+

p0
e+

r%
+=

(a
0+

hz
.=

+0
1+

(0
c+

))
0+

#0
##

q%
1-

g1
e-

-0
1+

#0
##

pe
0+

-1
h)

61
)+

an
1+

--
ng

fo
%f

)0
)+

f%
oz

-=
-[

11
)+

q1
%-

:#
1#

+0
1+

--
=r

j1
%-

ho
ri

#-
ra

(0
c+

i1
n+

,1
8-

r+
%=

%1
r-

##
0#

Python 3 176 Area
I don't use underscores in this program, so I decided to replace all spaces with underscores for added readablity.  Make sure to replace them back to spaces when failing to put it back together.
I Blocks:
1456

"jtr

\)\~

tris

],i)

t=""

2697

t(t[

_r+2

_r_i

O Blocks:
i_
s_

_;
32

6#
an

".
+-

t)
in

n(
_[

""
(c

ap
ri

L Blocks:
  =
#14

  .
\n"

  ;
"(t

  i
T%"

  o
:=i

  r
ioj

  6
mp#

J Blocks:
6
2(h

5
574

#
"=t

7
spl

f
o__

s
(s_

n
];#

0
t=_

*
#)(

T Blocks:
=_1
 _

295
 r

21,
 r

,2)
 .

Z Blocks:
46
 ""

"5
 3"

#t
 )n

1t
 ),

S Blocks:
 ge
34

 nt
68

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

authors: Олег Миронов

authors: Ээгийнээ Ээгий

sort: votes