-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeadFish In Gray Snail
464 lines (400 loc) · 7.99 KB
/
DeadFish In Gray Snail
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
"#This is the number DeadFish works on."
POP a numbers a000
"#This shows the numbers during output and is updated when the command is o."
POP a "show numbers" a
"#I use carry to indicate repetition for incrementing (9 to 0) and decrementing (0 to 9)."
POP a carry a0
POP a "empty input" a"Enter code in the input box."
"input more commands"
OUTPUT "Number: [show numbers]
[empty input]"
INPUT commands
"analyse commands"
POP instruction commands [commands]
GOTO "input more commands" [instruction] ""
GOTO "o command" [instruction] o
"#These are all the digits of the number."
"#Temp is used in case the command is not valid."
POP a temp a[numbers]
POP hundreds temp [temp]
POP tens temp [temp]
POP ones temp [temp]
GOTO "s command" [instruction] s
GOTO "d command" [instruction] d
GOTO "i command" [instruction] i
"#It was not a valid command."
GOTO "analyse commands"
OUTPUT "[instruction] takes it here."
INPUT ok
"o command"
POP a "show numbers" a[numbers]
OUTPUT "Number: [show numbers]"
GOTO "analyse commands"
"s command"
GOTO "possibly valid square" [hundreds] 0
GOTO "to 000"
"possibly valid square"
GOTO "square [tens][ones]"
"d command"
POP a digit aones
"#This will go to decrement 1, decrement 2, etc. depending on what ones is."
GOTO "decrement [ones]"
"finished with decrement"
"#If carry = 0, I can stop decrementing."
GOTO "completely finished with increment/decrement" [carry] 0
"#If digit is hundreds, no more decrementing is possible."
GOTO "completely finished with increment/decrement" [digit] hundreds
"#This is in case we have just decremented tens, so we have to decrement hundreds."
GOTO "decrement digit is tens" [digit] tens
POP a digit atens
GOTO "decrement [tens]"
"decrement digit is tens"
POP a digit ahundreds
GOTO "decrement [hundreds]"
"completely finished with increment/decrement"
"#In DeadFish implementation, 256 and 0-1 (999 in this case) become 0."
GOTO "to 000" [hundreds][tens][ones] 256
GOTO "to 000" [hundreds][tens][ones] 999
POP a numbers a[hundreds][tens][ones]
"numbers is changed"
POP a carry a0
GOTO "analyse commands"
"#Numbers is just set to 000."
"to 000"
POP a numbers a000
GOTO "numbers is changed"
"i command"
POP a digit aones
"#This will go to increment 1, increment 2, etc. depending on what ones is."
GOTO "increment [ones]"
"finished with increment"
"#If carry = 0, I can stop incrementing."
GOTO "completely finished with increment/decrement" [carry] 0
"#I capped the amount of digits at 3."
GOTO "completely finished with increment/decrement" [digit] hundreds
"#This is in case we have just incremented tens, so we have to increment hundreds."
GOTO "increment digit is tens" [digit] tens
POP a digit atens
GOTO "increment [tens]"
"increment digit is tens"
POP a digit ahundreds
GOTO "increment [hundreds]"
"#The variable carry becomes 1 here."
"decrement 0"
POP a [digit] a9
POP a carry a1
GOTO "finished with decrement"
"decrement 1"
POP a [digit] a0
POP a carry a0
GOTO "finished with decrement"
"decrement 2"
POP a [digit] a1
POP a carry a0
GOTO "finished with decrement"
"decrement 3"
POP a [digit] a2
POP a carry a0
GOTO "finished with decrement"
"decrement 4"
POP a [digit] a3
POP a carry a0
GOTO "finished with decrement"
"decrement 5"
POP a [digit] a4
POP a carry a0
GOTO "finished with decrement"
"decrement 6"
POP a [digit] a5
POP a carry a0
GOTO "finished with decrement"
"decrement 7"
POP a [digit] a6
POP a carry a0
GOTO "finished with decrement"
"decrement 8"
POP a [digit] a7
POP a carry a0
GOTO "finished with decrement"
"decrement 9"
POP a [digit] a8
POP a carry a0
GOTO "finished with decrement"
"#The variable carry becomes 1 here."
"increment 0"
POP a [digit] a1
POP a carry a0
GOTO "finished with increment"
"increment 1"
POP a [digit] a2
POP a carry a0
GOTO "finished with increment"
"increment 2"
POP a [digit] a3
POP a carry a0
GOTO "finished with increment"
"increment 3"
POP a [digit] a4
POP a carry a0
GOTO "finished with increment"
"increment 4"
POP a [digit] a5
POP a carry a0
GOTO "finished with increment"
"increment 5"
POP a [digit] a6
POP a carry a0
GOTO "finished with increment"
"increment 6"
POP a [digit] a7
POP a carry a0
GOTO "finished with increment"
"increment 7"
POP a [digit] a8
POP a carry a0
GOTO "finished with increment"
"increment 8"
POP a [digit] a9
POP a carry a0
GOTO "finished with increment"
"increment 9"
POP a [digit] a0
POP a carry a1
GOTO "finished with increment"
"square 00"
POP a numbers a000
GOTO "analyse commands"
"square 01"
POP a numbers a001
GOTO "analyse commands"
"square 02"
POP a numbers a004
GOTO "analyse commands"
"square 03"
POP a numbers a009
GOTO "analyse commands"
"square 04"
POP a numbers a016
GOTO "analyse commands"
"square 05"
POP a numbers a025
GOTO "analyse commands"
"square 06"
POP a numbers a036
GOTO "analyse commands"
"square 07"
POP a numbers a049
GOTO "analyse commands"
"square 08"
POP a numbers a064
GOTO "analyse commands"
"square 09"
POP a numbers a081
GOTO "analyse commands"
"square 10"
POP a numbers a100
GOTO "analyse commands"
"square 11"
POP a numbers a121
GOTO "analyse commands"
"square 12"
POP a numbers a144
GOTO "analyse commands"
"square 13"
POP a numbers a169
GOTO "analyse commands"
"square 14"
POP a numbers a196
GOTO "analyse commands"
"square 15"
POP a numbers a225
GOTO "analyse commands"
"#16 squared is 256, so that's what I put here."
"square 16"
GOTO "to 000"
"#I could have stopped here and been fine."
"#However, I decided to implement the others"
"#because I think it runs faster."
"square 17"
POP a numbers a289
GOTO "analyse commands"
"square 18"
POP a numbers a324
GOTO "analyse commands"
"square 19"
POP a numbers a361
GOTO "analyse commands"
"square 20"
POP a numbers a400
GOTO "analyse commands"
"square 21"
POP a numbers a441
GOTO "analyse commands"
"square 22"
POP a numbers a484
GOTO "analyse commands"
"square 23"
POP a numbers a529
GOTO "analyse commands"
"square 24"
POP a numbers a576
GOTO "analyse commands"
"square 25"
POP a numbers a625
GOTO "analyse commands"
"square 26"
POP a numbers a676
GOTO "analyse commands"
"square 27"
POP a numbers a729
GOTO "analyse commands"
"square 28"
POP a numbers a784
GOTO "analyse commands"
"square 29"
POP a numbers a841
GOTO "analyse commands"
"square 30"
POP a numbers a900
GOTO "analyse commands"
"square 31"
POP a numbers a961
GOTO "analyse commands"
"#Beyond this, the squares are too big for the overflow."
"square 32"
GOTO "to 000"
"square 33"
GOTO "to 000"
"square 34"
GOTO "to 000"
"square 35"
GOTO "to 000"
"square 36"
GOTO "to 000"
"square 37"
GOTO "to 000"
"square 38"
GOTO "to 000"
"square 39"
GOTO "to 000"
"square 40"
GOTO "to 000"
"square 41"
GOTO "to 000"
"square 42"
GOTO "to 000"
"square 43"
GOTO "to 000"
"square 44"
GOTO "to 000"
"square 45"
GOTO "to 000"
"square 46"
GOTO "to 000"
"square 47"
GOTO "to 000"
"square 48"
GOTO "to 000"
"square 49"
GOTO "to 000"
"square 50"
GOTO "to 000"
"square 51"
GOTO "to 000"
"square 52"
GOTO "to 000"
"square 53"
GOTO "to 000"
"square 54"
GOTO "to 000"
"square 55"
GOTO "to 000"
"square 56"
GOTO "to 000"
"square 57"
GOTO "to 000"
"square 58"
GOTO "to 000"
"square 59"
GOTO "to 000"
"square 60"
GOTO "to 000"
"square 61"
GOTO "to 000"
"square 62"
GOTO "to 000"
"square 63"
GOTO "to 000"
"square 64"
GOTO "to 000"
"square 65"
GOTO "to 000"
"square 66"
GOTO "to 000"
"square 67"
GOTO "to 000"
"square 68"
GOTO "to 000"
"square 69"
GOTO "to 000"
"square 70"
GOTO "to 000"
"square 71"
GOTO "to 000"
"square 72"
GOTO "to 000"
"square 73"
GOTO "to 000"
"square 74"
GOTO "to 000"
"square 75"
GOTO "to 000"
"square 76"
GOTO "to 000"
"square 77"
GOTO "to 000"
"square 78"
GOTO "to 000"
"square 79"
GOTO "to 000"
"square 80"
GOTO "to 000"
"square 81"
GOTO "to 000"
"square 82"
GOTO "to 000"
"square 83"
GOTO "to 000"
"square 84"
GOTO "to 000"
"square 85"
GOTO "to 000"
"square 86"
GOTO "to 000"
"square 87"
GOTO "to 000"
"square 88"
GOTO "to 000"
"square 89"
GOTO "to 000"
"square 90"
GOTO "to 000"
"square 91"
GOTO "to 000"
"square 92"
GOTO "to 000"
"square 93"
GOTO "to 000"
"square 94"
GOTO "to 000"
"square 95"
GOTO "to 000"
"square 96"
GOTO "to 000"
"square 97"
GOTO "to 000"
"square 98"
GOTO "to 000"
"square 99"
GOTO "to 000"
end