142
\$\begingroup\$

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.

Simple Example Cop Answers

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.

Simple Example Robber Answers

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

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

Safe Submissions

  1. ASP/ASP.Net, 14 (Jamie Barker)
  2. Befunge-98, 15 (FireFly)
  3. GolfScript, 16 (Peter Taylor)
  4. CJam, 19 (DLosc)
  5. GolfScript, 20 (user23013)
  6. Perl, 21 (primo)
  7. Python, 23 (mbomb007)
  8. Ruby, 27 (histocrat)
  9. SAS, 28 (ConMan)
  10. Ruby, 29 (histocrat)
  11. Python, 30 (mbomb007)
  12. JavaScript, 31 (hsl)
  13. Ruby, 33 (histocrat)
  14. Marbelous, 37 (es1024)
  15. Ruby, 43 (histocrat)
  16. PHP, 44 (kenorb)
  17. Ruby, 45 (histocrat)
  18. Marbelous, 45 (es1024)
  19. Python 2, 45 (Emil)
  20. PHP, 46 (Ismael Miguel)
  21. Haskell, 48 (nooodl)
  22. Python, 51 (DLosc)
  23. Python, 60 (Sp3000)
  24. Python 2, 62 (muddyfish)
  25. JavaScript, 68 (Jamie Barker)
  26. Mathematica, 73 (Arcinde)
  27. Haskell, 77 (proudhaskeller)
  28. Python, 90 (DLosc)
  29. C++, 104 (user23013)
  30. ECMAScript 6, 116 (Mateon1)
  31. C++11, 121 (es1024)
  32. Grass, 134 (user23013)
  33. PowerShell, 182 (christopherw)

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̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

$(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>

\$\endgroup\$
  • 4
    \$\begingroup\$ @xnor Yes, that's what it means. \$\endgroup\$ – PhiNotPi Nov 4 '14 at 20:00
  • 3
    \$\begingroup\$ You might want to forbid hashing... codegolf.stackexchange.com/questions/40304/… \$\endgroup\$ – NinjaBearMonkey Nov 4 '14 at 20:00
  • 7
    \$\begingroup\$ 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? \$\endgroup\$ – user2023861 Nov 4 '14 at 21:54
  • 62
    \$\begingroup\$ I thought "Oh, il just write a malbolge program, scramble it, and win this thing!". But then, i tried to write a malbolge program. \$\endgroup\$ – rodolphito Nov 5 '14 at 4:56
  • 8
    \$\begingroup\$ Warning: Cops, do not use Ideone to test your submissions, as it stores your programs and other people can see them. \$\endgroup\$ – rodolphito Nov 6 '14 at 4:48

242 Answers 242

1
\$\begingroup\$

C - 43 - Cracked

Code:

_main(_,su){_printf(&1+1+1+'1'),_TEA[0xD];}

Output

4

Tested with gcc

\$\endgroup\$
  • \$\begingroup\$ I've got a rather klunky solution for this one. \$\endgroup\$ – squeamish ossifrage Nov 5 '14 at 16:30
  • \$\begingroup\$ @Allbeert: I think your submission should be disqualified, since it produces different result at different time (even if it takes weeks to for the result to change). \$\endgroup\$ – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Nov 20 '14 at 19:16
  • \$\begingroup\$ @n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Agree. I actually missed the "regardless of when/where it is run" requirement. However, since it was already cracked, I think deleting this answer at this point will not really be productive. \$\endgroup\$ – Allbeert Nov 27 '14 at 18:02
1
\$\begingroup\$

PHP, Size 30

hill_top_101_(at)merchant.net;

Prints nothing with no errors, even when E_NOTICE is on.

\$\endgroup\$
  • \$\begingroup\$ What's that? Move the @ to the beginning and finished... This should be a challenge... \$\endgroup\$ – bwoebi Nov 5 '14 at 22:59
  • \$\begingroup\$ I overlooked something... will edit in a minute. Edit: seems like since my old PHP version @ behavior has changed. But it's useless to the challenge anyway. \$\endgroup\$ – Tryth Nov 5 '14 at 23:02
  • \$\begingroup\$ Cracked [that one is easy when you know the primitives to stop ;-)] \$\endgroup\$ – bwoebi Nov 5 '14 at 23:21
1
\$\begingroup\$

Lua, Size 49

=x)f+ nir  +opxdnx5x7 e+ = =0)rx(d1.*1t)x1o(,(i21

Output

1103219.5489201

There are 6 spaces and no newlines. I wrote it in Lua 5.1.4 to be specific, but it should work for any version.

\$\endgroup\$
1
\$\begingroup\$

ECMAScript 6, 116


Code

1na.M.))wg)iae/l)2e(s}w1(wowo((s*)r7Ean p.(),e,t?=1ttulh+gnoed+lol>(.ccEe(1ui,+t2e-2(m,ean+eeh(.)2o1a/e:{a)-re7r3)e6

Output

747135.7188700009

\$\endgroup\$
1
\$\begingroup\$

PHP, 33 (cracked by squeamish ossifrage)

Code:

(()),01;<=_eggghhhiiillnnrrssttt?

Output

52

Original

<?=strlen(highlight_string(0,1));


Tested on all PHP between 5.2 and 5.5.

\$\endgroup\$
1
\$\begingroup\$

PHP, 44 (cracked by bwoebi)

Code:

 $$(())07;;=@[]____aacddeeeeghhilmnoprsssttw

Tested different PHP versions.

Output (default for PHP 5.3.x, 5.4.x & 5.5.x),

valid

Tested on terminal (-r), PHP file and online here.

Notes:

  • You need at least PHP 5.3.0 or higher.
  • In some on-line testers it shows some warning, as it ignores @.
  • In some online testers it seems the output is seek instead for some reason (here), not sure why. At the same time it's a hint.

Original:

@$_=get_class_methods(new phar);die($_[70]);

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – bwoebi Nov 6 '14 at 14:34
1
\$\begingroup\$

PHP, 21 (cracked by PleaseStand)

Code:

<?=9*8*7*6*5*4/3/2/1;

Tested on PHP 5.6.

Output

14348907

Original

<?=9**8/3;/**124567*/

\$\endgroup\$
1
\$\begingroup\$

I tried cracking a few, but, NP-stupid-hard that this is, I didn't succeed.

Instead, here's a C program:

C, 39

Code

&&''((()))++9;;;<^____aaachiimmnnprtu{}

Output

_^]\[ZYXWV
\$\endgroup\$
  • 1
    \$\begingroup\$ This would be easy if I could rotate < into >. \$\endgroup\$ – feersum Nov 7 '14 at 5:37
  • \$\begingroup\$ Cracked \$\endgroup\$ – feersum Nov 7 '14 at 6:29
1
\$\begingroup\$

Lua (again), length 28 -- Cracked

There are no newlines, and 1 space.

hit).na.iat1 aai=an(ms(p)r*p

Output

4.9348022005447
\$\endgroup\$
1
\$\begingroup\$

Javascript, 30

(())M^aaaehhiilmmnrtttwx

Output:

0
\$\endgroup\$
1
\$\begingroup\$

Haskell, 42 (Cracked)

gS{int S;S{ Shin=pr}=Sta S=vinow;mari}deda

output

S

original code:

data S=S{}deriving Show;main=print S;S{}=S
\$\endgroup\$
1
\$\begingroup\$

Python, size 41[cracked by nneonneo]

Scrambled:

" "(()).01A\[]____aceeeeiillmnopprrrrttxx

Output:

search

Tested on CPython 2.7.8 and 3.3.2, Pypy3 2.3.1 and Ideone. I'm not sure whether this is really easy or really unfair.

\$\endgroup\$
  • \$\begingroup\$ I've got a subset of the characters that prints search on Python 2 but I can't get rid of the other ones... \$\endgroup\$ – feersum Nov 6 '14 at 17:01
  • \$\begingroup\$ @feersum That's interesting... I think I've copied it right without any spares though \$\endgroup\$ – Sp3000 Nov 6 '14 at 17:07
  • \$\begingroup\$ I certainly don't think it's the same one. I tried it on Python 3 and got a different result. \$\endgroup\$ – feersum Nov 6 '14 at 17:08
  • \$\begingroup\$ @feersum Hmm well if you can get it working somewhere verifiable (e.g. Ideone) then it should be okay \$\endgroup\$ – Sp3000 Nov 6 '14 at 17:09
  • \$\begingroup\$ Cracked. For me this falls in the "really easy" category. \$\endgroup\$ – nneonneo Nov 7 '14 at 20:19
1
\$\begingroup\$

CJam, size 13 (Cracked)

Code

,/*#%CEffGIKs

Output

030819828850379075460427536222159187897761502517030034671154875945928930530907551421904962649729

I think this should be hard without brute-forcing.

\$\endgroup\$
1
\$\begingroup\$

Little Man Computer

63 characters long.

Cracked by feersum [link].

This one may look overwhelming, but it's really easy to crack. You can find an online emulator (that uses Javascript) for LMC here.

When writing the source, I made sure each "box" I used was padded to three characters with leading zeros.

Source (original)

The original source.

Source (scrambled)

550780299002200104931956059169005996800195499090005297333101782

Output

51
\$\endgroup\$
  • \$\begingroup\$ Cracked, I guess. \$\endgroup\$ – feersum Nov 7 '14 at 9:29
1
\$\begingroup\$

Python, size 41 [cracked by DLosc]

Scrambled:

""(())****666;;;;====ceeinprtxxxxxxxxxxxx

Output:

134713546244127343440523266742756048896

Since my short submission got cracked, I thought I'd submit a shorter (and fixed!) version of another one I currently have up. This might make it a lot easier, but who knows.

\$\endgroup\$
  • \$\begingroup\$ Cracked. That was fun. \$\endgroup\$ – DLosc Nov 8 '14 at 6:14
1
\$\begingroup\$

Python 2, 29 bytes (cracked)

(.;i;=)de mnoprrrsssssssttyyy

No output.

\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$ – xnor Nov 4 '14 at 22:52
1
\$\begingroup\$

Javascript, 82, [Cracked by Shawn Holzworth]

Run in browser console, tested on Chrome 38

Code

bbbbbbbbbbbbvv'''' 00001245667799[[[[[[[[[[[[((=+++++++/=/++++++=))]]]]]]]]]]]];;

Output

u never find
\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – SLuck49 Nov 7 '14 at 18:55
1
\$\begingroup\$

ECMAScript, 90

Code

" "((((((()))))))+....;=FFFabcccdeeeffhhhiiiiiiilnnnnnnnnooooopprrrrsssttttttttttuuuuy{{}}

Output

function (){alert(this+"")}

\$\endgroup\$
  • \$\begingroup\$ @Sp3000 Nice work on the atob ones! \$\endgroup\$ – Cris Nov 9 '14 at 15:36
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$ – jimmy23013 Nov 9 '14 at 18:54
  • \$\begingroup\$ @user23013 Nice work! \$\endgroup\$ – Cris Nov 9 '14 at 22:00
  • \$\begingroup\$ @MartinBüttner amazing work on getting the exact solution. \$\endgroup\$ – Cris Nov 9 '14 at 22:01
1
\$\begingroup\$

QBasic, 43 bytes (Cracked)

Code:

GRANT EACH SAME;
DIST DAPPER 6;
ID$3
PEEP??

Includes 3 newlines.

Output:

??

(Output is followed by a newline.) Tested on QB64. I'm quite positive this won't work on Repl.it or other online QBasic interpreters.

\$\endgroup\$
1
\$\begingroup\$

Marbelous, 107

Marbelous is rather fun to program in.

Code

______________________!!***......000000000113444578:::::<<<<<=>>>>>>@@AAA\DDFF/////MM%%+++xxYYY{{{{{{}}}}}}

_ represents a newline.

Output

110000FFFFEEEEDDDDCCCCBBBBAAAA9999888877776666555544443333222211110000FFFFEEEEDDDDCCCCBBBBAAAA999988

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

\$\endgroup\$
1
\$\begingroup\$

QBasic, 79 bytes (Cracked)

One more, just for kicks: the meta-PPCG edition!

Code:

"Louis, I think this is the beginning of a beautiful friendship."
- Rick Blaine

(Note the newline.)

Output:

Iodine
\$\endgroup\$
1
\$\begingroup\$

QBasic, 37 bytes (Cracked)

Code:

PLAY "EN11E"
R = INT(11873105*RND)
?R

The code above (which includes two newlines) runs just fine: it plays a cute little tune and then outputs 8377039.* Only one problem...

Actual output:

 8946304

As always, output is followed by a single newline.

Original code:

PRINT 1801*5113 AND 1E7 R=LEN("RY?")

* Tested on QB64 Windows 7 desktop version. The pseudo-random RND should give the same result every time the program is run, unless seeded by RANDOMIZE. It's likely that the particular result will be different on different systems. But in any case (spoiler alert!)--the unscrambled program does not depend on RND. ;^)

\$\endgroup\$
1
\$\begingroup\$

Python, 55 chars [Cracked]

Works in both 2 and 3.

Code

((()))**+,.0112589:={}
____aacdefgiiimmmnnnoopprrrrsttu

Output

108723934648156901437468808002

Solution

The intended solution makes use of the fact that __name__ == '__main__' for scripts as well as in the REPL. More precisely, sum(map(ord,__name__)) == 801.

print(sum(map(ord,__name__))**10+1)
itforirngc={25.:89}

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Sp3000 Nov 11 '14 at 5:48
1
\$\begingroup\$

JavaScript, 42 Cracked by Optimizer

This should be pretty easy.

Code

tu curt infernnnnnnnnnno!(((())))+--58{||}

Output

1712

Run in browser console (result is REPL), tested in Chrome 38, Firefox 33, and IE11

\$\endgroup\$
1
\$\begingroup\$

Java - Size 97 (Cracked)

Code

""''{{}}(((())))...345:;[]^_     BSSaaabbbcccdeeeefgggiiiiiiillmmmnnnoooprrrsssssstttttttttuuvwyy

Output

X^Y

note: ends with a newline

\$\endgroup\$
1
\$\begingroup\$

Ruby, 23 (Cracked)

code scramble:

[[d++]8%-0]the...11 mops

output :

"lice"

tested on: http://repl.it/languages/Ruby/

\$\endgroup\$
1
\$\begingroup\$

C, 48 (Cracked)

Code

main(fma){fma=(0.9-'gpfx'),printf("%ddel",fma);}

Output

-1378246

Original Solution

main(f){f='ma'-lgamma(0xfe.dp9),printf("%d",f);}

Pretty simple.

\$\endgroup\$
  • \$\begingroup\$ my attempt. I don't like it very much, but it fits too well to be a coincidence. \$\endgroup\$ – Art Nov 11 '14 at 12:08
1
\$\begingroup\$

Rust, 123 characters

"{{{{{{{   -   }}}}}}}  > pgttts* ==== (((((%00xxeee,,:  +miiiiiiiiii  999aa   222222!  nnnnnnnn  /o1)))))  lffrrrrrrr3fff"

Output, no newline at the end:

97584

You may use Rust Playpen for experimentation if you don't have Rust installed.

There is a hint:

tr/gio_.ocupkzwwaaeeeeiiC/.ojdtkrnnlliic

Clojure, 96 characters

(*(((+((([]  (((=(=(( /[0]012222223999 adddeeeeffghiiiii  mnnnnoopq  rrrrr   rstwxx)))))))))))))

Same output, same algorithm, same identifier names, same hint.

Update

This version is solved. I have posted the version 2.

\$\endgroup\$
  • \$\begingroup\$ Are warnings required / disallowed / irrelevant? \$\endgroup\$ – kennytm Nov 13 '14 at 12:12
  • \$\begingroup\$ Original code does not produce warnings. It also does not contain comments, throw-away assignments or unused identifiers. \$\endgroup\$ – Vi. Nov 13 '14 at 12:33
  • \$\begingroup\$ Rust part cracked. \$\endgroup\$ – kennytm Nov 13 '14 at 20:03
1
\$\begingroup\$

DC (28) (cracked)

Code:

++01111<[]ddlllnnnnsssssssx

Output:

13610152128364555

Source:

Original: 1ss[lsd1+ss+dn11ls<n]sn0lnx
Cracked: [ls+dn11ls1+dss<n]sn1ss0lnx

Explanation

This is made up of a macro [ls d 1+ ss + d n 11 ls < n] that is stored in register n. It loads the value from s, duplicates, it, adds 1 to it, stores that value back in s duplicates the value on the stack, prints that off (n is the print without return), and then compares register s with the value 11. If the value that was in s is less than 11, it invokes the macro stored in register n. A value of 1 is used to initialize register s and 0 on the main stack. The macro n is then loaded and executed.

Sequence with spaces:

1 3 6 10 15 21 28 36 45 55

\$\endgroup\$
1
\$\begingroup\$

Rust + Clojure, version 2

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.

\$\endgroup\$

protected by squeamish ossifrage Jan 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).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.