148
\$\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\$
32
  • 4
    \$\begingroup\$ @xnor Yes, that's what it means. \$\endgroup\$
    – PhiNotPi
    Nov 4, 2014 at 20:00
  • 3
    \$\begingroup\$ You might want to forbid hashing... codegolf.stackexchange.com/questions/40304/… \$\endgroup\$ Nov 4, 2014 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\$ Nov 4, 2014 at 21:54
  • 66
    \$\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\$
    – vero
    Nov 5, 2014 at 4:56
  • 9
    \$\begingroup\$ Warning: Cops, do not use Ideone to test your submissions, as it stores your programs and other people can see them. \$\endgroup\$
    – vero
    Nov 6, 2014 at 4:48

245 Answers 245

1
3 4
5
6 7
9
1
\$\begingroup\$

Python [both], 154 characters (Cracked)

Code

""""%(((((((()))))))),,,,,-...////00011111133355888==[[[[]]]] ________aacccdddeeeefffffghiiiiiiiiiiiiijjjjjllmnnnnnnnoooooooppprrrrrrrrsttttuuu

That's twelve (12) spaces.

Output

ruby

\$\endgroup\$
2
  • \$\begingroup\$ Does "both" mean that the code needs to work for both versions of Python or just 1? \$\endgroup\$
    – Sp3000
    Nov 5, 2014 at 4:15
  • \$\begingroup\$ nvm, cracked \$\endgroup\$
    – Sp3000
    Nov 5, 2014 at 4:18
1
\$\begingroup\$

PHP, 13 - Cracked

Code:

abcde(())@i;_

Output:

abc

Original:

die(_(@abc));

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

Python 2 - 38 Cracked

Code

lp[__et._i(ri`2(]-:)pn1[s:)]t~i]t.`r[_

Output

beta

Now with 100% less '' ;)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked :) \$\endgroup\$
    – Sp3000
    Nov 5, 2014 at 14:54
1
\$\begingroup\$

Java 6+, 101 bytes (Cracked)

Works on Ideone

class t{public static void main(String[]a){short free=420;System.out.println("'t'p't'(d);;++=>/|");}}

Result:

1274127634633143115415747343141

Mostly unscrambled for ease of cracking. :)

(No it doesn't output 't'p't'(d);;++=>/|)

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

C - 43 - Cracked

Code:

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

Output

4

Tested with gcc

\$\endgroup\$
3
  • \$\begingroup\$ I've got a rather klunky solution for this one. \$\endgroup\$
    – r3mainer
    Nov 5, 2014 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\$ Nov 20, 2014 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, 2014 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\$
3
  • \$\begingroup\$ What's that? Move the @ to the beginning and finished... This should be a challenge... \$\endgroup\$
    – bwoebi
    Nov 5, 2014 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, 2014 at 23:02
  • \$\begingroup\$ Cracked [that one is easy when you know the primitives to stop ;-)] \$\endgroup\$
    – bwoebi
    Nov 5, 2014 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
  • 2
    \$\begingroup\$ Cracked \$\endgroup\$
    – r3mainer
    Nov 6, 2014 at 14:01
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\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – bwoebi
    Nov 6, 2014 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
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\$
2
  • 1
    \$\begingroup\$ This would be easy if I could rotate < into >. \$\endgroup\$
    – feersum
    Nov 7, 2014 at 5:37
  • \$\begingroup\$ Cracked \$\endgroup\$
    – feersum
    Nov 7, 2014 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
1
\$\begingroup\$

Javascript, 30

(())M^aaaehhiilmmnrtttwx

Output:

0
\$\endgroup\$
1
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
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\$
5
  • \$\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, 2014 at 17:01
  • \$\begingroup\$ @feersum That's interesting... I think I've copied it right without any spares though \$\endgroup\$
    – Sp3000
    Nov 6, 2014 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, 2014 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, 2014 at 17:09
  • \$\begingroup\$ Cracked. For me this falls in the "really easy" category. \$\endgroup\$
    – nneonneo
    Nov 7, 2014 at 20:19
1
\$\begingroup\$

CJam, size 13 (Cracked)

Code

,/*#%CEffGIKs

Output

030819828850379075460427536222159187897761502517030034671154875945928930530907551421904962649729

I think this should be hard without brute-forcing.

\$\endgroup\$
1
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\$
1
  • \$\begingroup\$ Cracked, I guess. \$\endgroup\$
    – feersum
    Nov 7, 2014 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\$
1
  • \$\begingroup\$ Cracked. That was fun. \$\endgroup\$
    – DLosc
    Nov 8, 2014 at 6:14
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
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – SLuck49
    Nov 7, 2014 at 18:55
1
\$\begingroup\$

ECMAScript, 90

Code

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

Output

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

\$\endgroup\$
4
  • \$\begingroup\$ @Sp3000 Nice work on the atob ones! \$\endgroup\$
    – Cris
    Nov 9, 2014 at 15:36
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Nov 9, 2014 at 18:54
  • \$\begingroup\$ @user23013 Nice work! \$\endgroup\$
    – Cris
    Nov 9, 2014 at 22:00
  • \$\begingroup\$ @MartinBüttner amazing work on getting the exact solution. \$\endgroup\$
    – Cris
    Nov 9, 2014 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
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
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
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\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Sp3000
    Nov 11, 2014 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
1
\$\begingroup\$

Java - Size 97 (Cracked)

Code

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

Output

X^Y

note: ends with a newline

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

Ruby, 23 (Cracked)

code scramble:

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

output :

"lice"

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

\$\endgroup\$
1
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\$
1
  • \$\begingroup\$ my attempt. I don't like it very much, but it fits too well to be a coincidence. \$\endgroup\$
    – Art
    Nov 11, 2014 at 12:08
1
3 4
5
6 7
9

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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