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

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

!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

abcde(())@i;_

abc

die(_(@abc));