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

# 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 # Python 3 - size 34 [cracked by FireFly] Scrambled: print(....__str__) [[(4,)=={-6}]]; Output: . The scrambled code runs fine, but it's not what you want ;). ## Intended solution Awkwardly, my red herrings backfired on me, and I only realised a few minutes after posting. The intended solution was: _={};_[6.,...]=_ print(str(_)[-4]) If we print out _, we get: {(6.0, Ellipsis): {...}} If you add a list or a dictionary to itself in Python, the string representation replaces that part of it with ...! Yes, that means you can do things like: a=[] a.append(a) print(a[0][0][0][0][0][0][0][0]) :) • Cracked. :) – FireFly Nov 11 '14 at 3:25 • Ah... I should've thought of that too.. since I've seen similar things (recursion detection) in other pretty-printers. Didn't occur to me that it'd be represented with an ellipsis. Nice one, too bad about the not-so-red herring. – FireFly Nov 11 '14 at 3:37 ## Java, size 134 (Cracked) Code: "''"{}{}[]()()()()()() <<<<<<< +++-===^ ..;;;; 11113444578999 aaaaabcccccdefgghhhiiiiiiiillmmnnnnnnnnnooopprrrrrrrssssSSStttttttttuuvy Output: ^74 ^376 ^2280 ^17512 ^139368 ^1114216 ^8913000 • What's the whitespace in the output? A trailing \n / (char)10 on each line? – Peter Taylor Nov 11 '14 at 15:57 • @PeterTaylor a trailing newline, yes – Olavi Mustanoja Nov 11 '14 at 16:08 • There are only 134 characters in the list. Is there some missing whitespace? – feersum Nov 11 '14 at 21:53 • @feersum Oops, my texteditor gave me a wrong number :/ fixed – Olavi Mustanoja Nov 11 '14 at 21:56 • Cracked – feersum Nov 11 '14 at 23:15 # Ruby, size 17 ## Code --::<<>>??Wip ## Output 1 • Cracked. I'm really interested in the original code though. ^^ – Martin Ender Nov 13 '14 at 9:25 # CJam, size 51 Thought I'd give this a shot! Code ""%)))))****+++,/::@ABBBBJJSSUWYYYZZ[]____accdeimos Output Bond, James Bond. • – jimmy23013 Nov 13 '14 at 19:03 # Ruby, 45 Code %()[]./ 0123456789_abcdefghijklmnopqrstuvwxyz Output 9410663329978946297999932 Original Code p %q[zyfnhvjkwudebgmacsxrl].to_i(36)/51074892 See charredUtensil's hack attempt in the comments for a great explanation. And yes, I generated the code randomly. I hoped the "pangram" approach would paralyze people with the number of options. • Cracked by charredUtensil. – FireFly Nov 14 '14 at 20:44 • Almost cracked, but not quite. And time's almost up. – histocrat Nov 14 '14 at 21:24 ## Python shell: 15 chars I had this strange urge not to include any 0's, 3's, or 7's. 11124455566899^ Output (to shell): 339018 • – es1024 Nov 15 '14 at 7:02 # PHP, 44 [SAFE] ## Code: ""(())46;=BFGHNOWWZ_aaabbcddeeeejjloopssvwyy Works on PHP 5.3-5.6. A bit long, but I hope it's difficult. ## Output 4096 ## Original code eval(base64_decode("ZWNobyBwaGFyOjpHWjs=")); which is the same as: eval(base64_decode(base64_encode("echo phar::GZ;"))); ## Explanation The code will print predefined constant GZ of Phar class which is just compression constant (0x00001000 = 4096). Then the code is encoded with MIME base64 text format and eval'ed (executed). Note that base64 is data encoding format (not hashing or cryptographic function). • I wrote a script to test every program beginning with ZWNoby. But I excluded programs containing :: because :: at the wrong place would generate a fatal error, and I didn't think there is a :: in the answer... – jimmy23013 Nov 17 '14 at 4:15 # Python, size 60 [safe] Scrambled: \n ((((()))))***,-0123:=____aaaabdegiilmmmnnoopprrrrsttttu Output: 1177652997443428940314 This probably still falls on the moderately-okay-to-crack side, but I thought the idea might be interesting. \n is a newline. ## Solution The number, searchable on OEIS, is the sum of the first 23 factorials. To implement a factorial function without any ifs for the base case we use Python's short circuit evaluation and the quirk that 0**0 evaluates to 1. t=lambda _:0**_ or _*t(_-1)or i print(sum(map(t,range(23)))) • Does this work in both versions of Python, or just in Py2? – DLosc Nov 9 '14 at 10:16 • @DLosc Should work on both versions. I tested on 2.7.8 and 3.3.2 – Sp3000 Nov 9 '14 at 10:17 # Ruby, 33 [safe] Code: &(())*09:==_yogurt puns...perturb Output: [0, [0]] [1, [1]] [2, [2]] [3, [3]] [4, [4]] [5, [5]] [6, [6]] [7, [7]] [8, [8]] [9, [9]] Source: e=r=p *(0..9).group_by(&:untrust) Explanation: e=r= is red herring filler (chosen to create the anagram "puts group_by return"). (0..9).group_by takes a block, passes each number from 0 to 9 into it, and creates a hash mapping distinct outputs of the block to the input. But instead of a literal block, I'm using the & syntax, which calls to_proc on the :untrust symbol to create a proc that "taints" each thing passed into it (which does nothing in this context), and returns the input. So each item in the range gets its own bucket. p * then converts the hash to an array of arguments of the form [key, value_array], and prints each on its own line. ## SAS, 17 (Cracked) %%()1;>>aabelptuv Outputs 0 • Is this actually a full program? From what I read here it looks like any full SAS program needs at least two semicolons, as well as some sort of RUN directive. – Martin Ender Nov 5 '14 at 13:01 • Yes it is, and what makes you think that two semicolons are needed? There's more to SAS than procs and data steps, as suggested on that page... – user3490 Nov 5 '14 at 17:59 • Just checking. I don't know the first thing about SAS, and after skimming that first section it sounded like that's the structure of any SAS program. – Martin Ender Nov 5 '14 at 18:01 • It is a program, and it's been cracked. codegolf.stackexchange.com/a/41199/32668 – ConMan Nov 7 '14 at 2:44 # Python 3, size 48 (Cracked) #print(']'2p/')'\xdh))2[:roo,h+(2*e'rw)/r(d'o(() # Output head Hopefully this one lasts a bit longer... • Cracked. Pretty sure this is the intended answer. – Sp3000 Nov 5 '14 at 5:55 ## GolfScript (13 bytes) (Cracked) &+,,../224?{} Expected output: 1234260885218145824583458445854586253225388392299142924142925142926142927142928302928497409497409 # Mathematica, 73 72 bytes [Safe] (I miscounted the bytes when I made the post.) ## Code: """"#&()*,,01>@@@@@[[]]StrongSolemnNiceLustyTensorSextetNastiesEastCamp ## Output: 0.5 + 14.1347 I ## Original code: N@(ToExpression@Last@Select[Names@"System*",StringCount[#,"eta"]>0&])@1 # Marbelous 45 [SAFE] ## Chars ^^^^^^^^^^!!&&000004459:<<<>>>\\EE//V{{{{}}}} Each ^ is a placeholder for a newline. ## Output Z{-8H ## Source 44 {} :{} }0E5 << }0 E9 &0&0 >>\/ >V!! /\{<{0 {} is a board that calculates (((}0 * 3 - 23) mod 256) - 27)/2. This is a Linear Congruential Generator, with its output modified to fit in the printable ascii range more often. The program terminates at the first output that is not a printable ascii character. 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 is safe now, so you should post your program to protect your submission. – user10766 Nov 20 '14 at 5:48 # Marbelous, 37 [safe] ## Code ^^^^^^^^!!-0002:::<<<<>>>>\F///WW{{}} ^ represents a newline; no ^s are to be used. ## Output lHp ## Original Source F2 >: :>: }0 <<}0 -W// << >W!! /\{0{> This passes 0xF2 into the board >:, which finds 2*(3*}0-32) mod 256, checks to make sure the result is greater than 32, and if so, outputs it down and left. The down marble is emitted as a character, and the left character is passed into >: again. 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). ## SAS, 28 (SAFE) %1(STAR)SPY,&2STUD;BUNNIES,% Outputs I (that's capital letter i) Solution: %PUT%SUBSTR(&SYSENDIAN,2,1); Which outputs the second character of the automatic macro variable SYSENDIAN (which takes the values BIG and LITTLE) to the log. • Going to give this one more day, then add the solution. – ConMan Nov 17 '14 at 22:18 • Well, I'm safe. – ConMan Nov 19 '14 at 22:26 # J - 14 char Going for the gold. Edit: I have been recently made aware that this code performs differently depending on whether you are using a 32-bit or 64-bit version of the latest J (j803). If this is grounds for disqualification, let me know: otherwise, I would concede a crack as an unscrambling that gives the correct answer on at least one of the two versions. Scrambled: 7*8..?56!/x\+/ 32-bit output: 2704156 64-bit output: 2722721 • Does this code always produce the same output? (I'm no expert in J, but I thought ? was used to generate random numbers) – r3mainer Nov 27 '14 at 19:34 • @squeamishossifrage Yes, that's correct, and yes, it always produces the same output. – algorithmshark Nov 27 '14 at 20:12 • I suspect the fact that it makes 2 different answers has do with the fact that the answer is really big, which would make sense if it uses factorial. – Bijan Apr 4 '17 at 0:15 # CJam, 19 bytes (SAFE) Code: %\@_@){;_0}*__*)\15 (A few smileys survived the factory explosion...) Output: 10120125854501259106171741725012526265263117252614371738261720339343012 Solution: 1_{_@)_@_*)\%}50*\; Calculates and concatenates together the first 51 terms of the following sequence: a[1] = 1 a[n] = (a[n-1]**2+1)%n The sequence increases rapidly, but every time a[n] gets above n, it gets knocked down again by the modulo operation. Here's the same thing with spaces inserted: 1 0 1 2 0 1 2 5 8 5 4 5 0 1 2 5 9 10 6 17 17 4 17 2 5 0 1 2 5 26 26 5 26 31 17 2 5 26 14 37 17 38 26 17 20 33 9 34 30 1 2 ## Perl - 21 bytes (safe) ~$is^*peter**+working

(the above evaluates to 1, btw)

65534

### Original

s**$~^wkirgo*ee+print Explanation The code performs a substitution which is evaluated, and then the result of that is evaluated (ee). The variable$~ starts its life as STDOUT, so that $~^wkirgo evaluates to$?-=2;.

The variable $? is also special, in that it is stored internally as an unsigned short. Decrementing it by two wraps around to 65534. # ASP/ASP.Net - 14 [SAFE] ### Code <%=Len('12')%> ### Output 1 ### Answer <%=1)''Len(2%> (Basically the equivalent of writing <%=1%>) # CoffeeScript, size 25 [Cracked] ## Code the terse tales // [.] ## Output false You can try it out here in the "Try CoffeeScript" tab. # JavaScript, 26 (cracked) later(103>(8-9)&80>4|10>9) ## Output 999 • – jimmy23013 Nov 4 '14 at 23:16 # PHP, Size 14 (Cracked) aaaaaa:::::??; Prints nothing when notices are turned off (no warning or fatal error messages). ## JavaScript, 61 (Cracked) ### Code x=next facile tortuously inept encrypter.{}()()()()(4-1);;ffo ### Output ring • Pretty sure that the last t is supposed to be o instead. Please correct me if I am wrong. – Optimizer Nov 5 '14 at 12:43 • Cracked based on the above assumption. If my assumption was wrong, I will remove the answer and this comment. – Optimizer Nov 5 '14 at 12:48 • You're correct. Sorry I really messed that one up trying to be clever with the anagram. – jsh Nov 5 '14 at 13:40 • Heh, no issues. I knew that the only way to get String is with two typeof on a function. – Optimizer Nov 5 '14 at 13:41 • FYI the original used typeof(typeof 1) – jsh Nov 5 '14 at 13:43 # Python 3, size 37 (Cracked) Code: int(22 ** 2 ** 2+range(irr)[]__npof_) Output (space separated): 0 1 4 9 16 25 36 49 64 81 • Cracked. – xnor Nov 4 '14 at 21:51 • @xnor Sorry, nope. – matsjoyce Nov 5 '14 at 7:37 • @matsjoyce it is now, see the comments. – isaacg Nov 5 '14 at 7:56 # Python 2, 101 ## Code "rne) n(sxx+ai(cpi)% ( *2n+f 1 )corii\.5n /r +5xeini+"h(5te4437f3)xjxo2]2or[)%(#"g r"+"lf/r2 # 1xn"h5 ## Output '4 [# ;4 E4 ## Y4 c4 • I can match the output but for one character. :( It feels like I've tried everything, but I'm not even sure if I'm close to the intended answer. I give up now. Please feel free to call this safe. I'm really interested to see the solution. – Emil Nov 29 '14 at 15:00 # Ruby - 58 (Cracked) puts 00000000111222344455556677888889^^^^aacdddddefffxxxxx Yeah you need to xor the hexadecimal literals in this one... Output: 1436068433 Hope this lasts more than my last one... • Cracked :-) How long did the last one survive? – r3mainer Nov 6 '14 at 0:16 • @squeamishossifrage 2.5 hours… It lasted even shorter than the last one ;-) – bwoebi Nov 6 '14 at 0:17 # Brainfuck, 118 chars [cracked by feersum] Scrambled: [>.<]++++++++++++++++++++++++++++++++++++++++++++++------<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[[[[[[[]]]]]]] Output: q$V4yQ!

This won't win, but there just had to be one. Assumes no cell wrapping, and works even if the tape has no cells to the left. I don't know how BF is scored, so I've put down chars.

For a BF program, 118's not that long...

## Explanation

The intended solution was ++++[>++++<-]>[>+>>>+>>>>+<<<<<<<<-]>>+++++++>+++++>+>+++++[>++++++++<-]+++>>++>[[<[>>+>+<<<-]>>[<<+>>-]<-]<]>>>>[+.>]. The ASCII values are [113, 36, 86, 52, 121, 81, 33], from which we can subtract 1 to get [112, 35, 85, 51, 120, 80, 32]. This can be achieved by building the numbers [16, 7, 5, 17, 3, 40, 2, 16] then multiplying pairwise.
However, as feersum points out, this is completely irrelevant in BF as long as you can golf your code down to be short enough.

• The code looks like a robot shooting lasers from eyes to a steel wall! :D – Optimizer Nov 6 '14 at 8:20
• Cracked – feersum Nov 6 '14 at 9:37

# C, 30 (cracked by feersum)

## Code

_L%"p;at(_N()m_Enin{_}diIf)",r

## Output

1
• Cracked – feersum Nov 6 '14 at 15:21

# ECMAScript, 26

Run in a Chrome browser console

$( convenient )({"awful"}) # Output$ {}

• Should I run it in Console ? Does it require Jquery to be on the page ? Please mention these in your post. – Optimizer Nov 6 '14 at 19:54
• @Optimizer running in console is correct. I choose not to answer your second question because knowing that answer is something you can answer this without. – Cris Nov 6 '14 at 20:01
• Cracked. – Martin Ender Nov 6 '14 at 20:14
• @MartinBüttner Nice work! – Cris Nov 6 '14 at 23:55