# Unscramble the Source Code

Note: This challenge is now closed to new cop submissions. This is to ensure that no one can post submissions that only remain uncracked because there aren't enough robbers interested in the challenge anymore.

In this game of cops-and-robbers, each cop will write a simple program to give a single output. They will then make public four things about their program:

1. The language
2. The program length
3. The desired output
4. A scrambled-up version of the source code

Then, the robbers must unscramble the source code so that their program functions like the original.

# Cop Rules

You are to write a simple program, which the robbers will try to recreate.

Your original program must have a simple functionality: upon execution, it outputs a single string/number and halts. It should give the same output regardless of when/where it is run, and should not depend on extra libraries or the internet.

Your program and output must use printable ASCII (newlines and spaces allowed). The output should be no more than 100 characters long, and the program should take less than about 5 seconds to run on a reasonable machine. You are also not allowed to use hashing (or other cryptographic functions) in your program

Then, you provide a scrambled-up version of the source code and the required output. You can scramble up your source code however you may like, as long as characters are conserved.

Your score is the shortest program you have submitted which hasn't been cracked. After a period of one week, an uncracked submission will become immune. In order to claim this immunity, you should edit your answer to show the correct answer. (Clarification: Until you reveal the answer, you are not immune and can still be cracked.) The lowest score wins.

Perl, 20

ellir"lnto Wo d";prH

Hello World

Or...

Perl, 15

*3i)xp3rn3*x3t(

272727

# Robber Rules

Robbers will post their cracking attempts as answers in a separate thread, located here.

You have one attempt at cracking each submission. Your cracking attempt will be an unscrambled version of the source code. If your guess matches the description (same characters, output, and of course language), and you are the first correct guess, then you win a point. It is important to note that your program does not have to exactly match the original, simply use the same characters and have the same functionality. This means there could be more than one correct answer.

The robber with the most points (successful cracks) wins.

Your program was print "Hello World";. (Although print"Hello World" ; could have also worked.)

Your program was print(3**3x3)x3

# Unsolved Submissions

In order of time of posting. This list courtesy of many users.

$(function(){function e(){var e=$("#ignore-space").is(":checked");var t=$("#source").val().split("").sort();var n=$("#editor").val().split("").sort();var r,i=0;for(r=0;r<t.length;){if(t[r]==n[i]){t.splice(r,1);n.splice(i,1)}else if(t[r]>n[i]){i++}else{r++}}$("#display").val(t.join(""));n=n.join("");if(e){n=n.replace(/[\r\n\t ]/g,"")}if(n.length!=0){$("#status").addClass("bad").removeClass("good").text("Exceeded quota: "+n)}else{$("#status").addClass("good").removeClass("bad").text("OK")}}$("#source, #editor").on("keyup",function(){e()});$("#ignore-space").on("click",function(){e()});e()}) textarea{width:100%;border:thin solid emboss}#status{width:auto;border:thin solid;padding:.5em;margin:.5em 0}.bad{background-color:#FFF0F0;color:#E00}.good{background-color:#F0FFF0;color:#2C2} <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <h3>Scrambled Source</h3> <textarea id="source" class="content" rows="10"></textarea> <h3>Unused Characters</h3> <textarea id="display" class="content" rows="10" readonly></textarea> <h3>Your Solution</h3> <input type="checkbox" id="ignore-space" name="ignore-space"/> <label for="ignore-space">Ignore space characters</label> <div id="status" class="good">OK</div> <textarea id="editor" class="content" rows="10"></textarea> • @xnor Yes, that's what it means. – PhiNotPi Nov 4 '14 at 20:00 • You might want to forbid hashing... codegolf.stackexchange.com/questions/40304/… – NinjaBearMonkey Nov 4 '14 at 20:00 • You should probably specify that the winner must post the original source code after one week. What prevents me from posting gibberish and claiming that none of the robbers got the right answer? – user2023861 Nov 4 '14 at 21:54 • I thought "Oh, il just write a malbolge program, scramble it, and win this thing!". But then, i tried to write a malbolge program. – rodolphito Nov 5 '14 at 4:56 • Warning: Cops, do not use Ideone to test your submissions, as it stores your programs and other people can see them. – rodolphito Nov 6 '14 at 4:48 ## 243 Answers # Mathematica, 18 (Cracked) ## Code !!#&,-./02>@D[]ddd  ## Output -EulerGamma + Log[2]  # Ruby, 49 - cracked by nooodl Turned out a bit on the long side, but I still like it. ;) <><> <><> <><> <><> <><> %%%%$+?;
""""""''''''''


Newlines are significant. Output:

'
""


Original:

$><< <<'"'+?"<<<<"'";<<'%%' ' " " ' >>>>>>>>>' %% • cracked – Lynn Nov 7 '14 at 19:56 • @nooodl Aww, all that work with heredocs for nothing. :) – Doorknob Nov 7 '14 at 23:43 # Python 3, 37 bytes [cracked by Bhante Nandiya] Scrambled: ""((((()))))....abefiilllmnnprrssttuz  Output: 433  Trying some shorter Python submissions. Tested on Python 3.3.2 and Pypy3 2.3.1 (just in case). ## Explanation Solution : print(sum(b"a".zfill(len(str(...))))) Uses the b"..." notation for bytes, which unlike strings can be summed and also the ... Python Ellipsis object. ## C, 53 bytes [Cracked] ### Code {{(nr:xxx)()(fmax(~n,*x%-9));puts("strix siren?!");}}  ### Output 58980  • Cracked. – grc Nov 8 '14 at 1:10 # Python 2, 29 bytes (cracked) (.;i;=)de mnoprrrsssssssttyyy  No output. • Cracked. – xnor Nov 4 '14 at 22:52 # PHP (>= 5.3.0), 52 (cracked by bwoebi) ## Code:  $$(((())))*+++,12345:;;<<<@@___cfghiiiinooopprrrttw  ## Output: abcdefgh  ## Original: _:print_r(chr(3*pow(2,5)+@++i));if(@i<4<<1)goto _; • Cracked – bwoebi Nov 5 '14 at 17:27 # APL, size 17 (Cracked) ## Code , (())****\+33333  There is a space ## Output 27 3 3 4.434264882430378e+38  • Cracked. Finally. – Geobits Nov 8 '14 at 16:14 # Marbelous, 36 (Cracked) ## Code _________^!!00039:=>\CDD/OO++++rr{{}  _ represents a newline; _ is not to be used. ## Output 1110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110  ## Original Solution 9C Dr +O +O :Dr }0 =0 !!++ ^3/\{> {0 JS Marbelous Interpreter This requires cylindrical boards (i.e. marbles pushed off of the board on the left reappear on the right and vice-versa). This one should be much easier to crack than my previous Marbelous answers. • Cracked. I have to say, this was one of the more fun ones to tackle. :) – Martin Ender Nov 9 '14 at 2:41 # Ruby, 37 (Cracked by DLosc) p00t1s ^u^110222333444555666777888999  A lot like my other ruby answer, but this time with normal numbers :) Output: 6809101718  I believe this type of answer is uncrackable without brute force, if you can prove me wrong kudos to you! :) Apparently not... Kudos to Squeamish Ossifrage :) • – DLosc Nov 8 '14 at 23:38 ## C, 44 bytes (Cracked) ### Code main(){while(-n&&banana);printf("%a",n[1]);}  ### Output abb  Might be too easy, but maybe not. ### Original solution an;main(){while(printf(&"a%nb"[an],&an)-1);} • Cracked – feersum Nov 11 '14 at 13:51 ## Perl 5, size 27 (cracked) print(rar(pizza))=~--'tanz'  Output: ohm  Works under use strict. • cracked by Wumpus Q. Wumbley print'pin'=~tr(a-za)(za-z)r – hmatt1 Nov 6 '14 at 18:17 Python 2, 69 characters Output: tab  Code: temp[}s::nn) a ](r{mnrottr]e[p_[[3wf3sa]osi(_(;i)ttinb y.s)a]a_)_:n(_  Original As I don't have enough rep to comment, the original was: import tabnanny as __;print(__.format_witnesses({():[]}[()])[3:][:3]) • – kennytm Nov 12 '14 at 23:38 • I think you can always comment on your own posts, but editing the original into the question is a better idea anyway. – Martin Ender Nov 13 '14 at 15:51 # Interactive Python 2.6, 15 (Cracked) ## Code (33*(4*12+4))/1  ## Output 270379522836753144265438496266566370136712020517640818813356355859028442008312225243036620289437521825508656065633888910684906390684337129360048186258048309000927118105125771665297425865729520809425997055097487267500801951307326211801132325770579267579825036033131104326181952588158139706361336195297731164624948083473959541919960343244739151223433852746136342590068225162166489275334797736589658479803522799496232002081568176260061240500941862631613470208955583641209766953178421429600070039361764538653961951816L  ## Original code (43**314)/(2+1) • Please indicate the version of Python (unless you have tested on both versions and it works on both). This seems like Python 2, since there is a trailing L. – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 14 '14 at 18:21 • Sorry. I updated the header. – MrWonderful Nov 14 '14 at 19:20 • Cracked – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 14 '14 at 19:33 • The output should be no more than 100 characters long... – r3mainer Nov 14 '14 at 19:41 • Oops! Mea Culpa. My apologies. – MrWonderful Nov 14 '14 at 19:43 # Mathematica, 31 ## Code PowerMod[123456789,123456789,^]  ## Output 1617298209804017979868926932743750272386265163887231542207613855504645035580118031906932144113367511  • (Inspired by xnor's Python cops a few submissions above) – jcai Nov 16 '14 at 0:24 • I suspect PowerMod is a red herring or you've done something extraordinarily clever, because you need to generate a number at least as big as the output for the mod bit. That being said; I count 101 characters in the output, and that's two characters more than allowed. – Alex Van Liew Nov 17 '14 at 0:41 • The ouptut is exactly 100 characters long, which is allowed. The code and output are correct as stated. – jcai Nov 17 '14 at 5:17 • I must have miscounted, then. I got 101 when I fed it into wc -c. – Alex Van Liew Nov 19 '14 at 23:25 • @AlexVanLiew It is not easy to feed into wc -c directly without the trailing newline. – jimmy23013 Nov 20 '14 at 2:42 # Marbelous, 55 (Cracked) ## Code ________&&--......./0000000000001111111111:<<=@@@@\{}}}  _ represents a newline. ## Output t"  JS Marbelous Interpreter Unlike many of my other Marbelous cops, this one does not use cylindrical boards. • – jimmy23013 Nov 16 '14 at 0:49 # PHP (46 bytes) Here is another attempt, but now using PHP. The scrambled code: print(a=Y<dY^r^o0);(e++)or(heY+Yo);c5+f0;  You can run the scrambled version, it will output 0. The unscrambled code outputs this: 171819202122232425262728293031012345678910171717171717171717171717171717171717171717171717  Have fun with this one :) # Revealing the answer: More than a week has past (I submited this at 8th November 2014, today is 17th), and here is the expected answer: for(Y=a;Y^t++<50e0;Y++)echo(ord(Y^prin)); For the invalid answer, it should be this: for(Y=a;Y^t++<99e9;Y++)echo(ord(Y^prin)); Thank you for not cracking this one :) Old submission: (invalid because 1,4889251×10^77 Yotabytes is over the limit of 100 bytes) The scrambled code:  print(a=Y<dY^r^o9);(e++)or(heY+Yo);c9+f9;  You can run the scrambled version, it will output 0. The output that the unscrambled version produces: I'm really sorry, but the output won't fit here. But, for purpose of testing, you can remove ONE e (Unicode Character 'LATIN SMALL LETTER E' (U+0065)) and ONE 9 (Unicode Character 'DIGIT NINE' (U+0039)). By removing it, the output is the following: 17181920212223242526272829303101234567891017171717171717171717171717171717171717171717171717171818181818181818181818181818181818181818181818181818191919191919191919191919191919191919191919  There is NO FEASIBLE WAY TO POST THE CODE, since the code generated would be 1,4889251×10^76 Yotabytes long (Byte units, Google calculation). # Python 2, 13 This one might be very easy for some; for me it came as quite a surprise. Code: print (70-70)  Output: 49  • Cracked – histocrat Nov 19 '14 at 20:50 • Super easy. Also, you could've used a python shell and cut that down to 5 characters: 70-70 Example: repl.it – mbomb007 Jan 6 '15 at 21:02 ## Golfscript - 20 (Cracked) "open world thrill!"  ## Output hello world!  Lua 5.2.3, Size: 18 chars (Cracked) pghmint(rat.hue)<3  Output: true  • – NinjaBearMonkey Nov 5 '14 at 4:00 • Correct. Just saying that because you didn't get a chance to test it. – DivideByZero Nov 5 '14 at 5:03 ## Python, 28 (Cracked) Program: i(b)t14i])2*2tni*(pr2[3:n(n) Output: 100220321420320200100 # RPL (Reverse Polish Lisp), e.g. HP48, 24 characters (Invalid) Code:  122 / 73 CNT » + I «  Output (what goes onto the stack after running the code): "123"  It's been 7 days, 4 hours and a few minutes. The solution is: « C 3 12 7 2 / INT + » • Agh, it's been too long! And I don't have my calculator with me. Have a +1. – DLosc Nov 15 '14 at 17:45 • Who compiles the list of Safe Submissions? I tried to add this puzzle to it by editing the "question" of the thread but my edit was rejected. If my puzzle does not belong on the list because it was disqualified for any reason, it would be nice if I was told that was the case and possibly the reason. – Heimdall Nov 24 '14 at 0:15 • I suspect it's because it uses non-ASCII characters, as mentioned on your second submission. Too bad there isn't a dialect of RPL where you can use << >> instead. – DLosc Nov 25 '14 at 20:11 • @DLosc Yeah, I suspect the same. As no one looks here and because the issue may be relevant to many other languages, could you please comment to the question itself and ask what the situation is when a language requires certain non-ascii characters - does that mean that language is excluded from this Cops and Robbers contest? From reading the comments the rules were evolving after the contest started. I would have raised the issue myself but I can't comment yet because I'm a newbie to StackExchange. – Heimdall Nov 27 '14 at 12:24 • I'm pretty sure that's right: a language that requires non-ASCII characters is excluded. Otherwise, there would surely have been submissions in APL and Sclipting by now. Sorry! Full props to you for your RPL skills--even with the unscrambled code, I still don't know how this works. ;) What does C 3 do? – DLosc Nov 27 '14 at 19:51 # Ruby, 27 [safe] Code co-opt value("*222555;==^")  Output "4"  Original eval"putc o^=22;"*(55-o=52) Explanation Calls putc three times with the character codes 34, 52, and 34. # Haskell, 48 (safe) ## Code pencil=runner.vwxyz='a winter squirm upturn...';  ## Output [""]  ## Solution - main=w 'v'; w=print.uncurry seq.unzip.lex.return • is there a newline at the end of the output? – proud haskeller Nov 7 '14 at 22:56 • Nope, there isn't. Note the final ; though. – Lynn Nov 8 '14 at 0:14 ## Python 2, size 23 [SAFE] Using http://repl.it/ Scrambled -/*[st0r3:.1245689])(()  Output '110665.1105651'  Original Code (str(065/.814)*2)[9:-3] This takes the octal value 065 and divides it by .814 to create a longer decimal value. I then converted that to a string and repeated it twice by using *2. The final part takes a substring of that result, making it harder to know what went on. # Rust + Clojure, version 2 [SAFE] This is the second version of the task. The first version is here. Output, without the newline: 1283691742071510101818513212188161611241111219191910762714142222223591109301717171051225  There is a hint (the same as in version 1): tr/gio_.ocupkzwwaaeeeeiiC/.ojdtkrnnlliic  Now the task is more related to the hint compared to version 1. The algorithm is the same in Rust and Clojure versions, there are no comments, unused identifiers thow-away assignments. All identifier have 1-character names. ### Rust, 118 characters ====> -,,:!/""((((((())))))){{{{{{{}}}}}}}*%+++001111112235aaeeeeefffffgiiiiiiiiillmnnnnnnnnoprrrrrrrrsstttxxxx  ### Clojure, 106 characters == /(((((((((((((((())))))))))))))))[[]]*++00011112235adddeeefffgiiiiimnnnoopqrrrrrrrstxxxx  ### C, 128 characters <===== ,;;;;;;;/""((((((((())))))))){{}}*%%+++++001111112235adeeeffffiiiiiiiiiiiiimnnnnnnnnnoprrrrrrrrrrrrrttttttttuuuxxxx  ### Haskell, 83 characters ======|| _;;....((()))[]*+++011111122349aaddehiimmmMnoopprrrrrrsSttTuuvwxxxxx  ### Perl, 97 characters ===== ;;/..(((((()))))){{{{{}}}}}$$$*%+++011111122349beeeffffhiiiiiillnoprrrrrrrssssttuxxxx


### Shell, 170 characters

==                                 ;;;;;;;;;/((((((((((()))))))))))[[]]{}*%+++0111111111122349cccddeeeeeeeeeefffffhhhhhiiiiiiillnnnnnoooooopqrrrrrrssttt


Checked with dash, bash, ksh a zsh.

# Original source codes

⚠Note: without >! spolier marks.⚠



(the code is immediately visible below)



⚠Note: without >! spolier marks.⚠

### Rust

(does not work anymore with modern Rust)

fn x(r:int)->int{if r==1{1}else if r%2==0{x(r/2)+1}else{x(3*r+1)+1}}fn main(){for i in range(1,50){print!("{}",x(i))}}


### C

int x(int r){if(r==1)return 1;if(r%2==0)return x(r/2)+1;return x(3*r+1)+1;}int main(){int i;for(i=1;i<50;++i)printf("%d",x(i));}


### Perl

int x(int r){if(r==1)return 1;if(r%2==0)return x(r/2)+1;return x(3*r+1)+1;}int main(){int i;for(i=1;i<50;++i)printf("%d",x(i));}


### Clojure

(defn x[r](+ 1(if(= r 1)0(if(=(mod r 2)0)(x (/ r 2))(x (+(* 3 r)1))))))(doseq[i(range 1 50)](print (x i)))


### Shell

r(){ if [ $1 = 1 ]; then echo 1; elif [$(($1%2)) = 0 ]; then echo$((1+r $(($1/2))));else echo $((1+r$(($1*3+1))));fi;}; for i in seq 1 49; do printf r$i; done


## Output

5

I ran this in the math command-line tool, but it works just as well in a notebook.

# CJam, 18 (Cracked)

## Code

012234567889""**%~


## Output

444

• – jimmy23013 Nov 4 '14 at 22:53

# CJam, Size 12

### Cracked by user23013

!mop[ET_^~+1]


### Output

-214


My first ever CJam program. :)

• – jimmy23013 Nov 5 '14 at 4:00

# Python [both], 154 characters (Cracked)

## Code

""""%(((((((()))))))),,,,,-...////00011111133355888==[[[[]]]] ________aacccdddeeeefffffghiiiiiiiiiiiiijjjjjllmnnnnnnnoooooooppprrrrrrrrsttttuuu

That's twelve (12) spaces.

## Output

ruby

• Does "both" mean that the code needs to work for both versions of Python or just 1? – Sp3000 Nov 5 '14 at 4:15
• nvm, cracked – Sp3000 Nov 5 '14 at 4:18

# PHP, 13 - Cracked

## Code:

abcde(())@i;_


## Output:

abc


die(_(@abc));