SORTING - Sorting is easy

no tags 


Do you think sorting is easy?

try your luck
in brainfuck


For those who don't know that brainfuck is a programming language: Take a look at the converter to C. It will ignore every unknown command, therefore submitting a program in any other language won't necessarily lead to compile error, but certainly not to Accepted.


The input consists of a line of up to 1000 uppercase letters, terminated with a '\n' character (ASCII value 10).


The output should contain a line consisting of the same characters as the input line, but in non-descending order.




hide comments
Rafail Loizou: 2020-09-02 20:53:52

[BEFORE] I solved it but with more that 500 characters of code which is the source limit.I tried to make the code smaller but I can't go under 700 characters of code. For a BF problem shouldn't the source limit be higher?
[AFTER SOLVING] OK it is possible to solve it with less than 500 characters you just need to be a little paranoid with it and you will finally get it.
[AFTER REALIZING SOMETHING WAS MISSING] The problem setter should have but did not specify that one cell is enough to count the occurrences of each letter. So you don't have to consider that each cell's size is 8-bits thus the numbers you can represent is [-128,127] and thus plan to use more than one cell to count occurrences of one character. I hope he sees this soon and changes the instruction to include this specification; That the cell size is greater than 8-bits and enough to count up to 1000 which is the limit given. Alternatively and if you think that this gives out the answer then just tell people the cell size provided in the bff 1.0.6 implementation of BF or provide this link so they can calculate it themselves

Last edit: 2020-09-07 11:43:47
Vamsi Krishna Avula: 2014-12-12 09:13:37

Its easier than I expected and of course had a good time debugging.

Martijn Muijsers: 2014-01-09 02:24:47

Boom AC in one go! Thinking about it, writing it and debugging it all took me a long time, and I learned a lot! :)

Mitch Schwartz: 2013-08-18 14:05:14

I've seen it also on , maybe it's a bug on SPOJ that happens very rarely.

ওয়াসী (Wasi): 2013-08-18 13:26:01

Strange! the problem setter is the best solver. I've never seen this type of thing before.I've tried to solve my own problem FIZZBUZZ(though a tutorial one :P) but my solution didn't appear in the best solver list.
Is it possible for a problem setter to participate in his own problem??

Jitesh: 2011-11-03 10:17:36


Adrian Kuegel: 2011-11-02 14:29:57

you don't print the 'Z's

Jitesh: 2011-11-02 07:38:57

Firstly i got a TLE n now its giving me a WA....Can any one give some test cases...

Adrian Kuegel: 2010-08-23 10:55:13

you need to use brainfuck (check wikipedia if you don't know about it)

BACK: 2010-08-22 08:28:01

which language have 2 use...

Added by:Adrian Kuegel
Time limit:1s
Source limit:500B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Resource:own problem