# 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.

## A small tool to verify solutions, courtesy of n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

$(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 ## 242 Answers ## Python 3, size 74 (Cracked) Python just wasn't the same after being re-educated by Big Brother. Input: print(war is peace) print(freedom is slavery) print(ignorance is strength)  There are two newlines at the end of lines 1 and 2. Output: True True True  Note that each True is in its own line. • What's behind door 101? – FryAmTheEggman Nov 7 '14 at 0:31 • I originally had 2+2==5 as a fourth statement until I found that the = made it too easy. – xnor Nov 7 '14 at 0:32 • Nice 1984 reference. – Justin Nov 7 '14 at 0:40 • Cracked. That was excellent. – Sp3000 Nov 7 '14 at 1:41 ## Python 3, size 12 (Cracked) print (abcd)  My program produces no output and no errors. • Cracked. Nice, the solution is very counter-intuitive. – matsjoyce Nov 4 '14 at 20:50 • Very nice, I was going for int for a while. – Fox Wilson Nov 4 '14 at 20:51 • @matsjoyce Nicely done. That was my intended solution. – xnor Nov 4 '14 at 20:53 • @matsjoyce Yes, I expected someone would do this eventually. Still, I encourage everyone to not spoil themselves and try to solve it by hand. I assure you it's a cute solution. – xnor Nov 4 '14 at 20:56 • I think I got it. The solution I found does not work if I first type python and then type my solution at the prompt. But it does work, if I put my solution in a file and type python file. – kasperd Nov 4 '14 at 22:45 # CJam, size 20 (Cracked) ## Code "Stop, Hammer time!"  ## Output 2.956177636986737  • Cracked. – Dennis Nov 6 '14 at 3:06 # Python 2, size 50 ### Cracked We already know the Answer to the Question, but what's the Question? ### Code print *********************--///222222222222222222  Note that there are no trailing spaces or newlines. The only whitespace character is the single space after print. ### Output 42  I've attempted to balance code length and difficulty, but it wouldn't surprise me if I missed it a bit either way. Hopefully it's enough to discourage brute force, at least. • Cracked – Ypnypn Nov 4 '14 at 20:34 • This would have been better with size 42. – a CVn Nov 5 '14 at 13:52 ## Pyth - 71 Cracked ### Code C-3P0: "Sir, the possibility,..."* Han Solo: "Never Tell Me The Odds!"  ### Output 3720  *Originally, George Lucas had Han interrupt C3-PO.** **He called this his greatest idea since Jar-Jar. Interesting note: despite all the changes that Pyth has gone through, there is still a valid answer here! ### Original ts,*s,y30 l" : : i i Han Solo "eP-C"h"TsrhT ### Explanation The remaining characters go on the next line. Pyth only interprets the first line of a file. ts, make a 2-tuple and get their sum -1. * multiply: s,y30 l"..." sum the 2-tuple containing 2*30 and the length of the string (18). eP-C"h"T get the largest prime factor of h's ascii value minus 10 (47). srhT get the sum of numbers from 0-10. All in all, this basically just computes: (30*2+18)*(47)+55-1. After reading @isaacg's answer I noticed there is an extremely simple solution: *h30tC"y" which is 31*120. ### Updated *h30tC"y" "-P:Sir, e possibilit,... Han Solo: Never Tell Me The Odds!" Still works even after all this time... Sorry for poor explanation formatting, I don't know how to use spoiler blocks :S (@Sp3000 made it a bit nicer for you, though) Now you can run Pyth online! Try it here. Thanks @isaacg :) • The above may contain blatantly made-up information about the creation of Star-Wars. – FryAmTheEggman Nov 5 '14 at 16:49 • cracked – isaacg Nov 6 '14 at 3:40 • @FryAmTheEggman You can use tags in blocks, e.g. <br> – Sp3000 Nov 7 '14 at 14:50 # CJam, size 51 [SAFE] ## Code main(int argc,char* argv){printf("Hello, World!");}  ## Output 55 2292213229222231957511222223333751125537511222222135723331131931959319319  You can play around with it in the online interpreter. This should be more crackable than it looks. ### Hint Start with the second line of the output. A few digits don't appear in it all, and others suspiciously often. Why could that be? If you can decipher that, the rest should almost fall in place. ### Solution "that rrrrraging london Hail!v"{elccimf(;W))},(*,pa The weather must have been pretty bad when I came up with that anagram... The hint was supposed to point towards the fact that the second line is made up of squashed-together prime factorisations. I was hoping that from there it would be possible to determine how many and which characters go into the string, leaving only a few characters at the end. • Wait is this scrambled??? – TheDoctor Nov 9 '14 at 21:07 ## Befunge-98, size 15 [SAFE] ### Code "quick" *+.@\_j  ### Output 3314  ### Original "u_ji@q.+k*c " A curious but somewhat well-known feature of Befunge is that you can terminate a string with the same quote that begins it, which in essence pushes that entire line (except the quote) on the stack. As an extra trick, I re-use the same string again, by making use of u to reverse the instruction pointer. Then it's just some arithmetic: the core idea is to sum up all those values (which is done using k to repeat the + operation). • Which interpreter(s) have you tested it on, and in particular what assumptions do they make about cell bitwidth? – Peter Taylor Nov 13 '14 at 11:52 • @PeterTaylor I've tested it on cfunge under x86_64 linux. Some testing seems to indicate it uses signed 64-bit integers, although I can say that my solution doesn't depend on overflow semantics so I'm not sure if it matters. – FireFly Nov 13 '14 at 12:37 • Ok, so I shouldn't be looking for 8-bit overflows. Shame, that might have simplified it ;) – Peter Taylor Nov 13 '14 at 12:40 • Ugh. I made programs to print 3312, 3300, and several others near 3314. So close... – Justin Nov 16 '14 at 19:39 • @Quincunx excellent... :P – FireFly Nov 16 '14 at 20:40 ## GolfScript (16 bytes) [SAFE] %%()*../1129n{}~  Expected output: -117345085515973157874551915956356303213327583847247840186528288852476459638212404362749  Original source: n)~{.*911%(}./2% • Is this expected output excluding the trailing newline, or will the newline simply not be outputted? – ProgramFOX Nov 9 '14 at 18:22 • @ProgramFOX, the output will end in a newline. The only ways I know of avoiding that would require :. – Peter Taylor Nov 9 '14 at 23:20 # Ruby, 17 (Cracked) Going for something really short this time. inprt N=2,*'~~~%'  Output: 2 2  • Cracked. (With some help from Sp3000) – Martin Ender Nov 5 '14 at 19:11 # Python, 69 chars [cracked by grc] Scrambled: ((((((((((((())))))))))))),,,,accdddiiiiillmmnopprrrrrssssssttttttttu  Output: 1083  This one's just a harmless bit of fun :) Tested on CPython 2.7.8, 3.3.2 and for the heck of it PyPy3 2.3.1. ## Explanation Uses built-in functions str, dict, list to build up a string and then applies map with ord to convert the string to a list of ints, which are then summed. • Cracked. – grc Nov 5 '14 at 12:33 # Python, size 56 (cracked) ## Code for i in "iprint()".join(([2,3,7,0,9,chr((-7+732^70)]))) ## Output hi mom • Python 2? or 3? – Geobits Nov 4 '14 at 21:08 • @Geobits, either one works. – Fox Wilson Nov 4 '14 at 21:12 • Cracked. – user1354557 Nov 4 '14 at 23:43 # Python 3, 70 chars Scrambled: ""(((())))****++++222222222;;;;;=======cccccccccceeeiinnpprrttxxxxxxxx  Output (99 chars long): 388626024960000000000026872002432000000000000676169243200000000000007317718780000000000000028820330  ## Update It's been a week, so rather than posting the answer, here's a hint: Try taking the square root of the number and working from there # Pyth, 11 \\,,"$: Ndw


### Output:

",input(),"


# JavaScript, 94 Cracked by FireFly

alert(' '' '''((()))+++,,,,,,,,,,,,,000111111114444577888;;;;;======[[[]]]aaafhinorrrrvvvxx||)


## Output

fun in the sun


## Original

a=alert;v='';r=[1,7,8,14,11,8,14,10,0,5,14,4,7,8];for(x in r)v+=('h'+(1==0)+a)[r[x]]||'';a(v);

• I have a feeling, this won't work in all browsers/engines. What environment did you test this in? – Martin Ender Nov 10 '14 at 11:47
• Cracked. – FireFly Nov 10 '14 at 12:30
• Oh... and I was convinced you had alert first, since the indices matched up so well with the needed characters. Interesting coincidence. – FireFly Nov 10 '14 at 13:27
• I actually had it first too when I started working on it, but I changed it to reduce browser differences. – SLuck49 Nov 10 '14 at 13:41
• Doesn't work on Chrome. I have the latest version. It says Syntax Error: Unexpected String – Oliver Ni Jan 11 '15 at 3:57

print(succ(downcase!))$$..[[]]6e0<><_  Output: u  Original: 6.pincdwnca[]rescue><<!.to_s[((0))] • Cracked. – Martin Ender Nov 8 '14 at 14:14 • @MartinBüttner Heh, nowhere near the original indeed. But your solution is possibly even more terrifying than the original. ;) – Doorknob Nov 8 '14 at 14:18 • Hey there's a fish – TheDoctor Nov 9 '14 at 21:08 • So the print and downcase! were red herrings. I expected the answer to use puts, did not think of ><<. – kernigh Nov 9 '14 at 23:08 # Python 3, size 16 (Cracked) Code: help tim__rolo__  Output (with newline at end): Hello world!  • Cracked. – Martin Ender Nov 4 '14 at 21:16 • @MartinBüttner I knew someone has seen the easter egg... – matsjoyce Nov 4 '14 at 21:18 • I hadn't, but I was quick to google it. ;) To be honest, if I hadn't been in such a hurry, I probably could have seen that the remaining characters after hello were an anagram of import. ^^ – Martin Ender Nov 4 '14 at 21:18 # Perl - 47 (cracked by grc) Code (there is one space in there too)  """"$$((()))**....///;;[[]]~==01finoprrstx


Output:

012345012345012345012345012345


You can run it online here and it does work under strict and warnings.

• Is this a valid solution? – grc Nov 5 '14 at 5:54
• @grc I'd say it is valid! Nice work! It prints the right thing. If you want some hints on the version that runs under strict and warnings let me know. – hmatt1 Nov 5 '14 at 14:37

# Ruby, 33 - cracked by user23013

enpsttux [[[]]]++\-\**????...


Output:

[*]


Original:

puts ?[+[*?*..?]][$$-$$]+?\\.next

• Which version is this? – Lynn Nov 6 '14 at 23:07
• @nooodl I have 1.9.3, but there's nothing version-specific about this one. – Doorknob Nov 7 '14 at 1:14
• This is tough. Here's what I have so far: puts  is obviously going to be the first thing there, .next is another keyword that can be used, and the rest is some sort of sorcery with ruby $ variables and character array creation.... +1 – rodolphito Nov 7 '14 at 1:19 • – jimmy23013 Nov 7 '14 at 15:22 • @user23013 Nice! Not the original, though; I probably should have output characters that weren't actually in the source ;) – Doorknob Nov 7 '14 at 23:39 ## Python2, 132 characters ____ ,,,,:::''""""""""""((()))[[]]\\\0126aaaabcccceeeeeeeeeEffggiiiiiilllllmmmmnnnnnnooooopppppqqrrrrrrrrrssssStttttttuuvxxyy  Output (with a newline): chance  ## Updated version, 96 characters Answer to original version suggested the exec instead of compile+eval, so here is a simplified version: ____ :::''""(())[[]]\\\0126aaabcccceeeeeeeeEffiimmnnnnooopppqqrrrrrrrrrssStttttttuuxxxxyy  ## Update: cracked Fully cracked by Alex Van Liew and KennyTM. The original solutions were (scroll right to reveal the spoiler):  eval(compile('try: compile("from __future__ import braces","","single")\nexcept SyntaxError as q:\n\tprint q[0][6:12]',"","single")) exec('try:exec("from __future__ import braces")\nexcept SyntaxError as q:\n\tprint q[0][6:12]') The hint meant "Consider {}, which are not present in the source code".  • How many newlines are there? – Sp3000 Nov 6 '14 at 14:42 • None (not counting logical newlines like \n inside strings literals). With newlines the code could be shorter. – Vi. Nov 6 '14 at 14:48 • +1 for not giving enough xs and cs for me to do what I want to do :P – Sp3000 Nov 6 '14 at 15:25 • Shall I think up some hint? Let's start with a vague one: Don't count ones which exist. Count ones which do not exist. – Vi. Nov 9 '14 at 23:44 • – kennytm Nov 12 '14 at 23:10 # Ruby, 29 [safe] Trying to see how short I can get in Ruby without getting cracked. Code paper view otool$()**,.8<<=>


Output

[0][0, 3][0, 3, 6][0, 3, 6, 9][0, 3, 6, 9, 12][0, 3, 6, 9, 12, 16][0, 3, 6, 9, 12, 16, 20]


Original

eval <<p*8 o=*o,$>.write(o) p Explanation The first line creates a heredoc that starts on the next line and is delimited by the trailing p, then concatenates the resulting string to itself 8 times. Since it ends in a newline, this effectively creates a loop. The looped code assigns an array to the variable o, consisting of the elements in o.to_a (via the * shorthand), followed by the output of $<.write(o), which converts o to a string, prints it to STDOUT, and returns the number of bytes printed. A variable being assigned to for the first time is nil for the purpose of evaluating the right hand side, so on the first run *o is empty and write outputs nothing and returns 0. Each subsequent round outputs the array of bytes output on previous rounds. Using a p-delimited heredoc creates decoy methods for output, p and $><<, in the scrambled characters, that won't work because you need the bytecount. # PHP, size 49 [Cracked by Martin Büttner] ## Code sub(print2w,$+expect+$+one+$+str+$+in=$@~main$);  ## Output {main}  • Would you mind disclosing which PHP version you tested this with? – Martin Ender Nov 6 '14 at 1:12 • @MartinBüttner I won't specify the exact range, but everything from 5.3.0 up will have the correct result. – bwoebi Nov 6 '14 at 1:15 • Cracked. Only took like... 4 hours... – Martin Ender Nov 6 '14 at 1:50 • @MartinBüttner wow, congratulations! Didn't expect you to not give up. :-) – bwoebi Nov 6 '14 at 1:53 # MATLAB, 41 bytes ### Cracked by feersum ((((((snowy leopards can like magic))))))  ### Output 1  • Cracked – feersum Nov 6 '14 at 6:45 # Perl, 36 ← cracked by grc ## Code $()++..112279;;<<=__ffiinooprrrt{}


## Output

perl


Tested here

# Haskell, 100 Chars (Invalid, output too long)

## Code

//Sup
tl=[]
while(syn==(+j)) tl+=b.a();
//(: #jquery :)\\
$("#jquery").on("click", j=>alert(j==m))  ## Output: "\er\\e\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\"\\\\\\\\\\\\\"\\\\\\\ ## Original (#)=(>);(//)=(++) l=j.show main=putStr.l.l$l"eer"
j[]="\\"
j(y:u)=let(q,c)=break(#y)u in y:j c//j q

• I thought for a moment that I'm reading "Evolution of Hello World" question. – Vi. Nov 5 '14 at 1:45
• @Vi yeah, but I think that the Levenshtein distance is a tiny bit more than 7 in this post. – Zaq Nov 5 '14 at 2:05
• Output is longer than 100 chars – Lynn Nov 6 '14 at 22:50
• @Zaq: the size limitation is not on code size, it's on output! – Lynn Nov 7 '14 at 0:11
• Huh. And I guessed you did something with fix show. Definately uncrackable – proud haskeller Nov 7 '14 at 11:25

## J, 22 bytes

### Code

!%()1348:::bbceehorvxx


### Output (97 chars)

1226317306651180983274420265228191056569220222873505571155987454033425908908110103433163350999040


I expect this to be practically impossible...

# CJam, 32 bytes (cracked)

### Scrambled source

"Beware the Jabberwock, my son!"


### Output

4074552392882954617076720538102062920

• Hm, where did you get the idea for using a quote as scrambled CJam code. ;) – Martin Ender Nov 6 '14 at 10:35
• Cracked – jimmy23013 Nov 6 '14 at 13:02
• @MartinBüttner: That's a line from a poem, not a movie quote. Entirely different! – Dennis Nov 6 '14 at 16:47
• @Dennis Wait, mine wasn't from a movie either. (Not exactly from a poem, though. :D) – Martin Ender Nov 6 '14 at 17:32

## Pyth - 35 - Cracked

In the spirit of @MartinBüttner:

### Code

"Programming Puzzles and Code Golf"


### Output

4.459431618637297


Try to decode it online here.

• I've cracked it, but in the interest of getting more people to use Pyth, I'm temporarily removing my answer. – isaacg Nov 7 '14 at 5:02
• Alright, cracked. – isaacg Nov 8 '14 at 10:31

## TinyMUSH 3.1, 20

Scrambled:

(#ret,#3!#+#2i\2#,@)


Output:

3210

• How are we supposed to run this? Where is the language reference? (The link doesn't help here). – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 6 '14 at 2:18
• @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀h You can run this code by connecting to a MUSH running the appropriate TinyMUSH version. Browse here to find one where Server Type is "MUSH", or download the server source from here and run a MUSH yourself. – Muqo Nov 6 '14 at 2:41

# Python 3, length 110 [cracked by grc]

Scrambled (\n denotes a newline)

\n\n\n   ""((((())))),.......9::;===IOS[]__addeeegghiiiiiiiiijllmmnnoooooooppprrrrsssssssssstttttttttttuuuuuvwyyy


Output:

The better is Flat dense. break never of be do at never. If bad it honking


Here's another fun one - not meant to be hard, but just something unusual and puzzly. :)

## Explanation

The random-looking words are taken from the Zen of Python (PEP 20), which is automatically printed via the easter egg import this. The passage is just every ninth word, as hinted by the 9::[] present.
To extract every ninth word without automatically printing the passage when importing, we redirect sys.stdout to a StringIO().

• Cracked – grc Nov 6 '14 at 11:19

# Javascript, 29 - Cracked

Run in a Chrome browser console

### Code

23*47,(no,(.][j,i|i,j][.),on)


### Output

181


### Original code

[,,,].join(3)|[,4,].join(7)*2

## protected by squeamish ossifrageJan 10 '15 at 19:15

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).