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

2
\$\begingroup\$

Ruby, 49 - cracked by nooodl

Turned out a bit on the long side, but I still like it. ;)

<><>
<><>
<><>
<><>
<><>
%%%% $+?;
""""""''''''''

Newlines are significant. Output:

'
""

Original:

$><< <<'"'+?"<<<<"'";<<'%%'
'
"
"
'
>>>>>>>>>'
%%

\$\endgroup\$
  • \$\begingroup\$ cracked \$\endgroup\$ – Lynn Nov 7 '14 at 19:56
  • \$\begingroup\$ @nooodl Aww, all that work with heredocs for nothing. :) \$\endgroup\$ – Doorknob Nov 7 '14 at 23:43
2
\$\begingroup\$

Python 3, 37 bytes [cracked by Bhante Nandiya]

Scrambled:

""((((()))))....abefiilllmnnprrssttuz

Output:

433

Trying some shorter Python submissions. Tested on Python 3.3.2 and Pypy3 2.3.1 (just in case).


Explanation

Solution : print(sum(b"a".zfill(len(str(...)))))
Uses the b"..." notation for bytes, which unlike strings can be summed and also the ... Python Ellipsis object.

\$\endgroup\$
2
\$\begingroup\$

C, 53 bytes [Cracked]

Code

{{(nr:xxx)()(fmax(~n,*x%-9));puts("strix siren?!");}}

Output

58980
\$\endgroup\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – grc Nov 8 '14 at 1:10
2
\$\begingroup\$

PHP (>= 5.3.0), 52 (cracked by bwoebi)

Code:

 $$(((())))*+++,12345:;;<<<@@___cfghiiiinooopprrrttw

Output:

abcdefgh

Original:

_:print_r(chr(3*pow(2,5)+@++$i));if(@$i<4<<1)goto _;

\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – bwoebi Nov 5 '14 at 17:27
2
\$\begingroup\$

APL, size 17 (Cracked)

Code

, (())****\+33333

There is a space

Output

27 3 3 4.434264882430378e+38

Tested here.

\$\endgroup\$
  • 4
    \$\begingroup\$ Cracked. Finally. \$\endgroup\$ – Geobits Nov 8 '14 at 16:14
2
\$\begingroup\$

Marbelous, 36 (Cracked)

Code

_________^!!00039:=>\CDD/OO++++rr{{}

_ represents a newline; _ is not to be used.

Output

1110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110

Original Solution

9C Dr +O +O :Dr }0 =0 !!++ ^3/\{> {0

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 one should be much easier to crack than my previous Marbelous answers.

\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked. I have to say, this was one of the more fun ones to tackle. :) \$\endgroup\$ – Martin Ender Nov 9 '14 at 2:41
2
\$\begingroup\$

Ruby, 37 (Cracked by DLosc)

p00t1s ^u^110222333444555666777888999

A lot like my other ruby answer, but this time with normal numbers :)

Output:

6809101718

I believe this type of answer is uncrackable without brute force, if you can prove me wrong kudos to you! :)

Apparently not... Kudos to Squeamish Ossifrage :)

\$\endgroup\$
2
\$\begingroup\$

C, 44 bytes (Cracked)

Code

main(){while(-n&&banana);printf("%a",n[1]);}

Output

abb

Might be too easy, but maybe not.

Original solution

an;main(){while(printf(&"a%nb"[an],&an)-1);}

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – feersum Nov 11 '14 at 13:51
2
\$\begingroup\$

Perl 5, size 27 (cracked)

print(rar(pizza))=~--'tanz'

Output:

ohm

Works under use strict.

\$\endgroup\$
  • \$\begingroup\$ cracked by Wumpus Q. Wumbley print'pin'=~tr(a-za)(za-z)r \$\endgroup\$ – hmatt1 Nov 6 '14 at 18:17
2
\$\begingroup\$

Python 2, 69 characters

Output:

tab

Code:

temp[}s::nn) a ](r{mnrottr]e[p_[[3wf3sa]osi(_(;i)ttinb y.s)a]a_)_:n(_

Original

As I don't have enough rep to comment, the original was:

import tabnanny as __;print(__.format_witnesses({():[]}[()])[3:][:3])

\$\endgroup\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – kennytm Nov 12 '14 at 23:38
  • \$\begingroup\$ I think you can always comment on your own posts, but editing the original into the question is a better idea anyway. \$\endgroup\$ – Martin Ender Nov 13 '14 at 15:51
2
\$\begingroup\$

Interactive Python 2.6, 15 (Cracked)

Code

(33*(4*12+4))/1

Output

270379522836753144265438496266566370136712020517640818813356355859028442008312225243036620289437521825508656065633888910684906390684337129360048186258048309000927118105125771665297425865729520809425997055097487267500801951307326211801132325770579267579825036033131104326181952588158139706361336195297731164624948083473959541919960343244739151223433852746136342590068225162166489275334797736589658479803522799496232002081568176260061240500941862631613470208955583641209766953178421429600070039361764538653961951816L

Original code

(43**314)/(2+1)

\$\endgroup\$
2
\$\begingroup\$

Mathematica, 31

Code

PowerMod[123456789,123456789,^]

Output

1617298209804017979868926932743750272386265163887231542207613855504645035580118031906932144113367511
\$\endgroup\$
  • \$\begingroup\$ (Inspired by xnor's Python cops a few submissions above) \$\endgroup\$ – jcai Nov 16 '14 at 0:24
  • \$\begingroup\$ I suspect PowerMod is a red herring or you've done something extraordinarily clever, because you need to generate a number at least as big as the output for the mod bit. That being said; I count 101 characters in the output, and that's two characters more than allowed. \$\endgroup\$ – Alex Van Liew Nov 17 '14 at 0:41
  • 1
    \$\begingroup\$ The ouptut is exactly 100 characters long, which is allowed. The code and output are correct as stated. \$\endgroup\$ – jcai Nov 17 '14 at 5:17
  • \$\begingroup\$ I must have miscounted, then. I got 101 when I fed it into wc -c. \$\endgroup\$ – Alex Van Liew Nov 19 '14 at 23:25
  • \$\begingroup\$ @AlexVanLiew It is not easy to feed into wc -c directly without the trailing newline. \$\endgroup\$ – jimmy23013 Nov 20 '14 at 2:42
2
\$\begingroup\$

Marbelous, 55 (Cracked)

Code

________&&--......./0000000000001111111111:<<=@@@@\{}}}

_ represents a newline.

Output

t"

JS Marbelous Interpreter

Unlike many of my other Marbelous cops, this one does not use cylindrical boards.

\$\endgroup\$
2
\$\begingroup\$

PHP (46 bytes)

Here is another attempt, but now using PHP.

The scrambled code:

print($a=Y<$dY^r^$o0);($e++)or($heY+Yo);c5+f0;

You can run the scrambled version, it will output 0.

The unscrambled code outputs this:

171819202122232425262728293031012345678910171717171717171717171717171717171717171717171717

Have fun with this one :)


Revealing the answer:

More than a week has past (I submited this at 8th November 2014, today is 17th), and here is the expected answer:

for($Y=a;$Y^$t++<50e0;$Y++)echo(ord($Y^prin));

For the invalid answer, it should be this:

for($Y=a;$Y^$t++<99e9;$Y++)echo(ord($Y^prin));

Thank you for not cracking this one :)


Old submission: (invalid because 1,4889251×10^77 Yotabytes is over the limit of 100 bytes)

The scrambled code:

 print($a=Y<$dY^r^$o9);($e++)or($heY+Yo);c9+f9;

You can run the scrambled version, it will output 0.

The output that the unscrambled version produces:

I'm really sorry, but the output won't fit here.
But, for purpose of testing, you can remove ONE e (Unicode Character 'LATIN SMALL LETTER E' (U+0065)) and ONE 9 (Unicode Character 'DIGIT NINE' (U+0039)).
By removing it, the output is the following:

17181920212223242526272829303101234567891017171717171717171717171717171717171717171717171717171818181818181818181818181818181818181818181818181818191919191919191919191919191919191919191919

There is NO FEASIBLE WAY TO POST THE CODE, since the code generated would be 1,4889251×10^76 Yotabytes long (Byte units, Google calculation).

\$\endgroup\$
  • \$\begingroup\$ @MartinBüttner DANG IT! I will edit. \$\endgroup\$ – Ismael Miguel Nov 8 '14 at 11:04
  • \$\begingroup\$ @MartinBüttner Better now? \$\endgroup\$ – Ismael Miguel Nov 8 '14 at 11:21
2
\$\begingroup\$

Python 2, 13

This one might be very easy for some; for me it came as quite a surprise.

Code:

print (70-70)

Output:

49
\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – histocrat Nov 19 '14 at 20:50
  • \$\begingroup\$ Super easy. Also, you could've used a python shell and cut that down to 5 characters: 70-70 Example: repl.it \$\endgroup\$ – mbomb007 Jan 6 '15 at 21:02
2
\$\begingroup\$

Golfscript - 20 (Cracked)

"open world thrill!"

Output

hello world!
\$\endgroup\$
2
\$\begingroup\$

Lua 5.2.3, Size: 18 chars (Cracked)

pghmint(rat.hue)<3

Output:

true
\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$ – NinjaBearMonkey Nov 5 '14 at 4:00
  • \$\begingroup\$ Correct. Just saying that because you didn't get a chance to test it. \$\endgroup\$ – DivideByZero Nov 5 '14 at 5:03
2
\$\begingroup\$

Python, 28 (Cracked)

Program: i(b)t14i])2*2tni*(pr2[3:n(n)

Output: 100220321420320200100

\$\endgroup\$
2
\$\begingroup\$

RPL (Reverse Polish Lisp), e.g. HP48, 24 characters (Invalid)

Code:

$ 122 / 73 CNT » + $ I «

Output (what goes onto the stack after running the code):

"$123"

It's been 7 days, 4 hours and a few minutes. The solution is:

« C$ 3 $12 7 2 / INT + »

\$\endgroup\$
  • \$\begingroup\$ Agh, it's been too long! And I don't have my calculator with me. Have a +1. \$\endgroup\$ – DLosc Nov 15 '14 at 17:45
  • \$\begingroup\$ Who compiles the list of Safe Submissions? I tried to add this puzzle to it by editing the "question" of the thread but my edit was rejected. If my puzzle does not belong on the list because it was disqualified for any reason, it would be nice if I was told that was the case and possibly the reason. \$\endgroup\$ – Heimdall Nov 24 '14 at 0:15
  • 1
    \$\begingroup\$ I suspect it's because it uses non-ASCII characters, as mentioned on your second submission. Too bad there isn't a dialect of RPL where you can use << >> instead. \$\endgroup\$ – DLosc Nov 25 '14 at 20:11
  • \$\begingroup\$ @DLosc Yeah, I suspect the same. As no one looks here and because the issue may be relevant to many other languages, could you please comment to the question itself and ask what the situation is when a language requires certain non-ascii characters - does that mean that language is excluded from this Cops and Robbers contest? From reading the comments the rules were evolving after the contest started. I would have raised the issue myself but I can't comment yet because I'm a newbie to StackExchange. \$\endgroup\$ – Heimdall Nov 27 '14 at 12:24
  • \$\begingroup\$ I'm pretty sure that's right: a language that requires non-ASCII characters is excluded. Otherwise, there would surely have been submissions in APL and Sclipting by now. Sorry! Full props to you for your RPL skills--even with the unscrambled code, I still don't know how this works. ;) What does C$ 3 do? \$\endgroup\$ – DLosc Nov 27 '14 at 19:51
2
\$\begingroup\$

Ruby, 27 [safe]

Code

co-opt value("*222555;==^")

Output

"4"

Original

eval"putc o^=22;"*(55-o=52)

Explanation

Calls putc three times with the character codes 34, 52, and 34.

\$\endgroup\$
2
\$\begingroup\$

Haskell, 48 (safe)

Code

pencil=runner.vwxyz='a winter squirm upturn...';

Output

[""]

Solution

-

main=w 'v'; w=print.uncurry seq.unzip.lex.return

\$\endgroup\$
  • \$\begingroup\$ is there a newline at the end of the output? \$\endgroup\$ – proud haskeller Nov 7 '14 at 22:56
  • \$\begingroup\$ Nope, there isn't. Note the final ; though. \$\endgroup\$ – Lynn Nov 8 '14 at 0:14
2
\$\begingroup\$

Javascript - 10 (Cracked)

Scrambled Code

foeblast()

Output

W29iamVjdCBXaW5kb3dd

Answer

btoa(self)

\$\endgroup\$
2
\$\begingroup\$

ASP/ASP.Net - 14 [SAFE]

Code

<%=Len('12')%>

Output

1

Answer

<%=1)''Len(2%> (Basically the equivalent of writing <%=1%>)

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

Mathematica, 29 (Cracked)

Code

FPP$cur[int]ion,retn;{2x=5+2}

Output

5

I ran this in the math command-line tool, but it works just as well in a notebook.

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

CJam, 18 (Cracked)

Code

012234567889""**%~

Output

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

CJam, Size 12

Cracked by user23013

!mop[ET_^~+1]

Output

-214

My first ever CJam program. :)

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

Python [both], 154 characters (Cracked)

Code

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

That's twelve (12) spaces.

Output

ruby

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

PHP, 13 - Cracked

Code:

abcde(())@i;_

Output:

abc

Original:

die(_(@abc));

\$\endgroup\$
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
    \$\begingroup\$ Cracked :) \$\endgroup\$ – Sp3000 Nov 5 '14 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\$

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.