# 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, 90 bytes (SAFE) Kinda long, but I enjoyed putting this together. Code: ??(((())))+++++++,1111111111111111111111:;;<<<<======>>>>>[[]]ehiilnnnnnnnnnnpppprrrsstttw  The ?s represent two newlines. Output: 6167185029251277541387741632208161040852042602130139041952976  Output is followed by a newline. Works in Python 2 or 3. Solution: n=11111+1111+111+1;p=str() while n>1111:n=[(n<<1)+n+1,n>>1][n>>1<<1==n];p+=str(n) print(p) Calculates several iterations of the 3n+1 function starting at 12334 and continuing until the value dips below 1111, concatenating the results together. For obfuscation, uses only 1's and bitwise operators to calculate the function (which would more straightforwardly be n/2 if n%2==0 else 3*n+1). ## C - size 19 Code: int main(){return;}  There is 1 space. Output: Segmentation fault  or similar. Compiled in http://codepad.org/ • OS? Compiler? Segmentation fault usually is the by product of undefined behavior, and it varies between systems. – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 19 '14 at 5:14 • @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ edited – Olavi Mustanoja Nov 19 '14 at 15:05 • – jimmy23013 Nov 20 '14 at 2:22 # Python [any] shell size 44 (Cracked) 4no_,2_[a(m] g]]fn_mie___e[nenr aa )1__[r3 _  # Output 'a'  # Haskell, size 34 (Cracked) Shuffled: pfdi0xf7(anI5i7r1):^b3nf=2x:t2tm0n  Output: -1121766947  • I'm tempted to claim that this violates the "you may not use cryptographic functions" rule, except that any self-respecting cryptographic function would use a big prime instead of 2^64 for its modulus... Perhaps if I knew a bit more I would know how to exploit this choice. Very clever choice of problem. – Daniel Wagner Nov 7 '14 at 8:05 • cracked – Daniel Wagner Nov 7 '14 at 9:06 • @DanielWagner Good job. I'd say that exponentiation isn't a cryptographic function, even with the 2^32 modulus. Perhaps I should have used ** instead of ^ to make the guess slightly harder. – Petr Pudlák Nov 7 '14 at 11:01 • Number Theory != Cryptography – recursion.ninja Nov 8 '14 at 16:53 # ECMAScript, 25 (Cracked) Executed on window object # Code applet.stellar[flyer,(a)]  # Output function alert() { [native code] } • Just double checking, are you sure, you're not missing a comma? (Alternatively, does it produce errors as a side effect?) – Martin Ender Nov 5 '14 at 23:16 • The built-in function alert isn't mentioned in the ECMAScript spec, so I think you need to be more specific about the execution environment in which this output is produced. – Peter Taylor Nov 5 '14 at 23:55 • There are 24 characters given in your answer – es1024 Nov 6 '14 at 3:10 • @MartinBüttner correct. Thank you for that. Adding comma. – Cris Nov 6 '14 at 12:48 • Cracked. – Martin Ender Nov 6 '14 at 12:54 # C++, 244 bytes (one linebreak, 19 spaces) (Cracked) ## Source  !#%''''''''''''''''''''''''((()))++,,,,,,,,,,,/00122224::;;;;;<<<<====>CCCCCCDDDDDD[[]]aaaaaaaaacccdddeeeffhhiiiiiillllllllllmmnnnnnnnnnnnnnnnnooooooooooooooooorrrrrrrrrrrrsssstttttttttttttttttttuuuuuuuuuuuuuuwwwwwww{{{{}}}}  ## Output hello world! ## A couple hints • Output is achieved using a really unorthodox process. • The source code isn't 'scrambled', per se. (Just alphabetized.) • How many spaces? I counted only 224 non-whitespace characters. With the initial space and new line, that makes 226 bytes, not 244. – squeamish ossifrage Nov 19 '14 at 23:01 • Cracked, I think – squeamish ossifrage Nov 19 '14 at 23:27 • I had a method in my scrambler that counted the number of bytes that were in the file it loaded into memory. It said '244 bites', so I went with that. (Edit: verified character count with an ascii counter online. 244 is accurate.) Also, @squeamishossifrage, It does the same thing, but the extra characters ARE used, not just tossed into the end. =P – Gabe Evans Nov 20 '14 at 0:16 • I just realized most of those characters are used in variable names. Didn't realize smallest score won. >_< – Gabe Evans Nov 20 '14 at 0:31 # Haskell, 77 this poorly mixed code: {tt))=Maprte((e)=))+-1%%&&tt} %%:i=ddeno:p:)illme((m;;;<=;()&&()):a6::1=(((no  output Should be 1 2 4 8 16 Code.exe: <<loop>>  Edit: To clarify: the code should be saved in a file named Code.exe. otherwise the output would have the actual file name instead of Code.exe. more than a week has passed since this was published. original version: main=mapM print(&);(&)=1:(&)%(&);(16:(:){})%t=t;(e:d)%(l:o)=(e+l):d%o;e<t=e-t  this uses a few tricks: a variable named (&) that isn't a function a record pattern not on a record (:){} a useless definition of < to get people confused what to do with the extra = sign the runtime prints <<loop>> because we entered into a trackable infinite loop (at the fifth element and on of (&)). • Regarding the last line, is it actually written to stdout? – FireFly Nov 8 '14 at 3:59 • @FireFly as an uncatched exception it is written to stdout and then the program terminates – proud haskeller Nov 8 '14 at 6:34 • When I checked locally, exceptions were printed to stderr for me (on linux), and not stdout. I suppose it might print to stdout on windows, though? Still seems a bit odd. – FireFly Nov 16 '14 at 0:27 • And you get a completely different message with jhc. – John Meacham Nov 20 '14 at 14:49 ## C - size 62 (Cracked) Code: )#<("pitiful tit,handfin descended in +18_minor.")>#(%{;__*}  There are 4 spaces and 2 newlines \n in the source (not in output). Output: 17  Possible error thrown not taken into account. • Would you please confirm the cracking attempt by user23013? The cracking attempt seems to have too many spaces. – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 20 '14 at 10:13 • @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ wasn't gonna until I got home, but looking at it quickly I'd say there's 5 spaces in his attempt. Only 4 spaces in the actual code, though, so doesn't pass. – Olavi Mustanoja Nov 20 '14 at 10:35 • @user23013 Sorry but 1 space too much – Olavi Mustanoja Nov 20 '14 at 10:35 • – es1024 Nov 22 '14 at 9:38 ## C - size 33 (Cracked) Code: #() {} * +257; adeeefiimnnnppprrtu  So 3 spaces and 1 newline Output: Exits with return code 173 ## Javascript, 35 Scrambled: a)o29t;((1lae1.2(ll=h3t(;rM)4)g)lll7 Output: 0.674284933420515 # Python 2, 45 [safe] Code: 3 ((([])))**,,::-=>ccddeeiinoopprrttuuuuuuw  (Contains one newline and no further whitespace.) Output: 67156035937662544426  Hint (though I'm not sure it helps): If you replace the 3 by a 4 the output grows to 993 digits. For 5 it's even 91585 digits. Solution: u=3 printreduce(pow,(u*u-(oct>id),)*u)[::u] Explanation: Okay, maybe this was overdone. :-) The (oct>id) was a red herring and is just a fancy way of spelling 1 because in Python functions are ordered alphabetically by name. Using tuple multiplication, the argument of the reduce function then boils to reduce(pow,(8,8,8)) which is ((8)**8)**8 or6277101735386680763835789423207666416102355444464034512896. Because this would be an easily recognizable number, it's then converted to a string and only every third digit is printed. # Python 2, 80 Source (original) "no %, *, any for loops, nor pow()" print int(str((61**38)/(702+4)+5)[9:]) Source (scrambled) " "% ((((())))) ***++,,,/ 0123456789 :>[]afiilnnnnnoooooo ppprrrrsstttwy  Output 28557152413644043173796536772347528819922074855728983445  This one demonstrates something pretty neat (and surprisingly poorly known): ## Python, 16 ### Code ""()7T\aeeelruvx  ### Output (from interpreter) -2  I can't say much without giving a big hint, but this depends on an interpretation of the rules that I think is fair, reasonable, and expected. I didn't make a separate answer for this next one since it bends the rules a little. It's technically still fully compliant, but it's a little outside their spirit. It's also really mean. I'm sorry. ## Python, 61 [SAFE-ish] ### Code (plus two newlines) # ((()))*****----012345:aabbbcccdeeeggggginnoorsttuvvvyzzz  ### Output (from file) 635587791019258855467865682634760304773233019345006266045081668082247125111784951775232  Update: explanation: As guessed in the comments, this is indeed rot13 encoded. The rules state "You are also not allowed to use hashing (or other cryptographic functions) in your program", but the character encoding defines how the editor interprets the bits that comprise the program, not the program itself. Clearly, this violates the spirit of the rule. Original source: #--coding:rot13-- sebz zngu vzcbeg* cevag(vag(ybt(5)**420)) • Is the second one using ROT13 encoding? Because, if so, yes that is pretty mean. :P – Sp3000 Nov 7 '14 at 8:21 • (Also if so you might want to specify that it's Python 2, not 3. Ignore me if I'm wrong though.) – Sp3000 Nov 7 '14 at 8:34 • The question forbids "cryptographic functions". ROT-13 is technically a cryptographic function, so it would be forbidden. – feersum Nov 7 '14 at 8:44 • I've cracked the first one, assuming Python 2 is acceptable. – squeamish ossifrage Nov 7 '14 at 8:52 • @imallett The question asks for a program. It's standard rules for the site that a program means a program, and not some code fragment which could be evaluated. And a cryptographic function is a cryptographic function regardless of how it is invoked. – feersum Nov 7 '14 at 21:08 # JavaScript, 24 characters Code: ('oogles').oil + 'chn';  Output: hi  (with newline) Works on pretty much any browser, or Node.js (but not Rhino). Should be very easy to crack. • Cracked. – Martin Ender Jan 2 '15 at 18:10 • Sorry, there was an extra period in the scrambled version. Your solution works, though! – 190n Jan 3 '15 at 0:14 # JavaScript, 72 [SAFE] Output: 35616001553385  Code scramble: Math.exp(unoat(exp){ecit((("x")ps.in(1.19+21)).sit())+flr()})loop[ferln]  Unscrambled: (function(exp){alert((""+exp.sin(1.21)).split(9)[1])+exp.floor()})(Math) # Python, 39 [Cracked] Scrambled code for{{5210},{101},{6}}at{print(("m.",))}  Output 06555  • Cracked yesterday but forgot to post here, sorry. – Uri Zarfaty Jan 6 '15 at 12:15 # Processing, 77 Scrambled code - // L0L => line(987654321); Lint( <.< ^=^ ;=; >=< ^ ); script {wh LLL >> LLL};  Prints this to the console - 11677374506454972755473030033  It also opens a small window with a grey square in it, the same thing that shows up when you run a totally blank sketch. I don't think there's anything I can do about this in Processing. Tested in Processing 2.2.1 but should work in pretty much any version. Thanks for playing! # PHP, 56 chars  ""$\$((())),.0;<=>??EFIL[\]______herecefhillnnoopppstw2


(begins with two spaces)

Output

3249

EDIT:

I thought this one was fairly easy.

Hint:

This code relies on just one math function.

# Python, 13 [Cracked]

Code

printline("")


Output

6

• – ProgramFOX Jan 10 '15 at 16:48

# Python 2 (Cracked)

### Scrambled Code:

int r*37230,
p rp tin * 73


### Output:

222222


# CMD, 9 (Cracked)

/0at!es!!


No spaces in source - Just a big fan of Oaties.

Output: 1

# Javascript - 15 (Cracked)

### Scrambled Code

''O1ahintsM.()+


### Output

0.8414709848078965O


EZ PZ :D

Math.sin(1)+'O'

## Python, size 15 (Cracked)

This one is for the gold, though I find that unlikely. Again using http://repl.it/

Scrambled

[~]/:.*03457:


Output

=> '6991'


Original Source

.03*7/5[::~4]
~4 is just a fancy way to write -3

• Cracked – squeamish ossifrage Jan 13 '15 at 7:59
• Does anyone know how I can correctly format the code in the solution? The backticks need to be escaped, but it'd be nice if the code could be formatted like code also (which normally involves surrounded with backticks, but it won't work.) Indenting with 4 spaces isn't working either. – mbomb007 Jan 13 '15 at 17:46
• @squeamishossifrage Thanks. – mbomb007 Jan 13 '15 at 21:11

# CMD, 21 (Cracked)

echo "/test!!">>afile


No files are produced.

Output: 0

### Original program

set /a"!echo>>!tfile"


I evaluate two separate strings with ! (negation), each producing 1 - then perform a logical shift >> on the two values - which produces 0.

# Javascript - 68 [SAFE]

### Scrambled Code

''''((( )))++,,.00012567;==ABCCISaaadeeffffghimnnooprrrrrssssssttvxx


### Output

9+10


var s=String,sf=s.fromCharCode;sf(57)+sf('0x2B')+parseInt('0x0A',16)

# Python 2, 78

int pint=2222222****************2222222****************2222222,
rp r= 61727176


### Output

16777216


UPDATE The output has a newline after it.

## Python, size 30 (Cracked)

This one is just for fun, since my last one wasn't solved. :D
Again using http://repl.it/

Scrambled

:: rsin[~rot13('0ddf') + 69][]


Output

=> 'rot13'


Original Source

Will be posted later, because I didn't like his workaround. Solve THIS instead. Nobody solved it! Muahahaha!

str(d for d in[])[9:6:~0]+'13'

For an explanation, go to the link above.                    ^

• Cracked – squeamish ossifrage Jan 13 '15 at 8:02
• It appears you found a workaround. Editing it to remove the possibility of that workaround. – mbomb007 Jan 13 '15 at 17:37

## Javascript (Node.js REPL), 11 bytes

Just for fun. Here is the verifier for the program that generates a circular list.

([x[0]==x])


Expected output:

[ [Circular] ]


## Spoiler (don't cheat!)

Spoiler since no cop solutions are allowed anymore (written by wizzwizz4): (x=[])[0]=x

# Python 2, 89 - Cracked

## Code

   ''''''''((()))*,,,,...12;;=BFGGIIIILPRaaaaaabceeeeeeffgggggiiiiiklmmmmmmnnoopprrrsttvw


## Output

No output to STDOUT ;)

• Cracked. Turns out no unscrambling was necessary! – feersum Nov 7 '14 at 9:34
• @feersum I don't know if it's allowed, but I clarified what my code should do... – Beta Decay Nov 7 '14 at 9:36
• "Your program and output must use printable ASCII." And no fair adding new output after I already cracked it... – feersum Nov 7 '14 at 9:37

# Java 6+ / Oracle's implementation (218 bytes)

## Code

 ((((((()))))))*+,...........
000000000111222225677;;;
DEIPPSSS\\\\\\aaaaaaaaaaaabccccccccddeeeeeeeeeeeeffggggh
iiiiiiiiiiiijjllllmmmmnnnnnnnnnooooooppppppqqqq
{{{{}}}}


There are 5 new lines and 1 space. No other invisible character.

## Output

723Unmatched closing ')'


With these many characters, it is probably open for many possibilities.

## Hint

I don't know if there is any other solution, but it seems I have limit the solution to the following direction quite well.

import
java.util.regex.*;
class{public
static
void
main(String){try{Pattern.compile(((()))+.....000000000111222225677DI\\\\\\aaacdeeeeeffggiijnnopqqqqrstttuuuuux,);}catch(PatternSyntaxException ){System.out.print();}}}


And second hint is long-standing bug.

• Hmm, seems familiar, didn't I already do that one? – feersum Nov 7 '14 at 9:35
• @feersum: Yes, it is a rehashed version, but slightly modified - not sure if it can be solved similarly, though. – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 7 '14 at 9:38

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