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
5
6
7 8 9
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\$
3
  • \$\begingroup\$ Are warnings required / disallowed / irrelevant? \$\endgroup\$
    – kennytm
    Nov 13, 2014 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, 2014 at 12:33
  • \$\begingroup\$ Rust part cracked. \$\endgroup\$
    – kennytm
    Nov 13, 2014 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
1
\$\begingroup\$

Marbelous, 144

Code

______________________________++++++++++----......///0000000000000000111134477889::::::<<<<<<<<<<<=>>>>>>>>>>>@@@@@@AABLPTU\\\^^^^^^{{{{{{}}}}}}

_ represents a newline.

Output

2.718281828459045

I'll probably regret leaving in so many numbers..

JS Marbelous Interpreter

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

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

Brainfuck, 39

Code

++++++++++++++++++++------...<<>>>>[[]]

Output

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

Python, 45

Code:

((((((()))))))+.1233445accehhiijlnnoprrrrsttv

Output:

0

Original

print(eval((chr(43)+chr(45)).join(str(321))))

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Sp3000
    Nov 13, 2014 at 21:40
1
\$\begingroup\$

Python shell: 21 chars

A slightly beefed-up version of my previous attempt that I hope is harder to brute-force.

00112233445566778899^

Output (to shell):

15788895283
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – es1024
    Nov 16, 2014 at 5:24
1
\$\begingroup\$

Python, 51 bytes (SAFE)

Code:

((((["tx*xx=2202022=xx*xt",prince:rinse+x*t]))));;;

Output:

86207823349459112201077150426144

Solution:

x=2*2*2+2;exec("x=int(str(x)[:],0x20);"*x);print(x)

Starting with x=10, interpret x as a number in base 32 and assign the result back to x. Repeat 10 times.

\$\endgroup\$
5
  • \$\begingroup\$ Works in both versions? \$\endgroup\$ Nov 11, 2014 at 8:22
  • \$\begingroup\$ Just double checking - exactly one comma? \$\endgroup\$
    – Sp3000
    Nov 11, 2014 at 8:46
  • \$\begingroup\$ @MartinBüttner Yes, should work on any version (tested with 2.7 and 3.3). \$\endgroup\$
    – DLosc
    Nov 11, 2014 at 19:45
  • \$\begingroup\$ @Sp3000 Exactly one. :) \$\endgroup\$
    – DLosc
    Nov 11, 2014 at 19:47
  • \$\begingroup\$ Good old exec, the [:] did well to confuse. \$\endgroup\$
    – Sp3000
    Nov 18, 2014 at 23:48
1
\$\begingroup\$

Javascript size 13 (Cracked)

Going for the shortest, runs on shell

([[])+]+[-}{]

Output

"0"
\$\endgroup\$
3
  • 1
    \$\begingroup\$ The question asks for programs. I'm not sure about the Python submission, but the JavaScript seems to require a shell. I don't know if that is allowed. (Also, different submissions generally go in different answers.) \$\endgroup\$
    – Dennis
    Nov 4, 2014 at 22:06
  • \$\begingroup\$ @Dennis Both of them go into shells, I split them up. \$\endgroup\$
    – Caridorc
    Nov 4, 2014 at 22:08
  • 3
    \$\begingroup\$ I count 13 characters. (And cracked it.) \$\endgroup\$ Nov 4, 2014 at 22:14
1
\$\begingroup\$

Python, 68 (Cracked)

Code

"""""""""#''''''(((((()))))),,,,,-0235;==CYbcdehilnooooooppprrrsstt{

Output

#123456789
\$\endgroup\$
1
  • \$\begingroup\$ Cracked - Think this should be the intended solution, or something similar at least \$\endgroup\$
    – Sp3000
    Nov 5, 2014 at 7:18
1
\$\begingroup\$

PHP, 52 (Cracked)

Code

$)6am;crcn--+i(shr_4;9(na(%d_ ))t$2)o5tmrd(frhieo3=;

Output

Wu]w.iB ZKlXV=(mYz(z,b,IlZ+Vi.J!5wMM6Dfa4N4^=]
\$\endgroup\$
2
  • \$\begingroup\$ Cracked! \$\endgroup\$
    – r3mainer
    Nov 5, 2014 at 1:04
  • \$\begingroup\$ Vi.?󠀠󠀠󠀠󠀠󠀠󠀠󠀠 \$\endgroup\$
    – Vi.
    Nov 14, 2014 at 2:09
1
\$\begingroup\$

Python 3 size 54 (Cracked)

(o'd)'op'/r),2\x'12.)w/)h],c'dp*((rx:(h('r'ol'ae#)[ere

Output

'head'
\$\endgroup\$
4
  • \$\begingroup\$ Does this have a print statement included or is it supposed to be run in a shell? \$\endgroup\$ Nov 5, 2014 at 4:27
  • \$\begingroup\$ Run in a shell. No print statement. \$\endgroup\$
    – Kyle G
    Nov 5, 2014 at 4:29
  • \$\begingroup\$ Solved. \$\endgroup\$ Nov 5, 2014 at 4:33
  • \$\begingroup\$ That works. Forgot about that pesky 'a'. \$\endgroup\$
    – Kyle G
    Nov 5, 2014 at 4:37
1
\$\begingroup\$

Perl, 39 (Cracked)

Code

//shredding($c_)=\\t_;$_=($r/~$p*2014);

Output

H

Tested here

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

ECMAScript, 29 (Cracked)

Code

1("HAlf PEnCesEveNthswunG".5)

Output

32768
\$\endgroup\$
6
  • \$\begingroup\$ Both this and your other submission seem to require a console/REPL environment, and are not full programs. \$\endgroup\$ Nov 5, 2014 at 22:52
  • \$\begingroup\$ You're on your way to cracking them if you see it needs a javascript console. The definition of full program is important. \$\endgroup\$
    – Cris
    Nov 5, 2014 at 22:56
  • 6
    \$\begingroup\$ I'm not sure how to understand that. I do have a solution that works in the console now. Is that valid, or is there an answer that does not rely on the result of an expression being printed automatically? \$\endgroup\$ Nov 5, 2014 at 23:44
  • \$\begingroup\$ @MartinBüttner if it works in the console it's valid. I wouldn't preclude a solution I haven't imagined also working. \$\endgroup\$
    – Cris
    Nov 6, 2014 at 12:57
  • \$\begingroup\$ Cracked. \$\endgroup\$ Nov 6, 2014 at 13:03
1
\$\begingroup\$

Mathematica, 35 characters (Cracked)

Code

'Pen & Pie Part Preprinters'====$$;

Output

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

Javascript: 47 chars (Cracked)

//if("rest")("it will tell a surprise tale!")()

Output:

a surprise!

PS: My original snippet does not contain any comments. Whoever takes a shot at this, try to crack that version.

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

Marbelous, 106

Code

_________________________!!0000011122223779999:::<<<<<<<<<<>>>>>>>>>>AAAbb\\\/MMNNOOOOOO+++++QQ{{{}}}}}}~~

_ represents a newline.

Output

3823160E090604030202

Hint

Hexadecimal couplets.

This output should hopefully look familiar to you.

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

C++11, 121 [SAFE]

Code

#include <iostream>
#include <cstdint>
using namespace std;
main(){{uint64_t b=-1,to(+'.');int uavlq(b);cout<<b-to,'d';}}

Output

2901942

Source

#include <iostream> #include <cstdlib> using namespace std; main(){auto t=div('_nnt-',641);int b{'-,'};cout<<(t.quot+b);}
Note that the answer uses cstdlib, not cstdint as given in the scrambled version.

uint64_t does require C++11....

\$\endgroup\$
1
  • \$\begingroup\$ I lol'd at swapping cstdlib for cstdint \$\endgroup\$ Nov 27, 2014 at 11:57
1
\$\begingroup\$

Python 2; 62 chars; Output: 100 chars; SAFE

Code:

    %%%''((((())))),-199;=[]___aaeeeeefggiiiillmnnnnooprrrstuv

Output:

1087654320987654316039744558401050205536516109500544976952359908183938933602037618678184519105773568

Solution:

e='%ie%i';print long(sum([eval(e%(_,_-1))for _ in range(99)]))

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

CJam, 14 (Cracked)

Code

1.2e35 6.78e9%

Output

108183.05975155532
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – DLosc
    Nov 25, 2014 at 18:11
1
\$\begingroup\$

JavaScript, 36

scrambled code:

trx=["bs","alie"];trx((x+x)guns(96))

output: ion

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

CJam, 47 bytes [safe]

Code

###'''(())**+-0112333479:KKKKNNN]__cdffmtt{{}}~

Output

316218750702865:484776333:983474443201156009:7420206870:545426587396511674:49954383540:8793516242242

This should be hard, I guess...

Hint

It's not 7 numbers separated by :. The : in the code is for variable.

Solution

'N)){~}:KK{1#1md'NNf-Kc((K*}93*]'0f+34_2#t3_7#t

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

Python 3, 21 [Cracked]

Code

pi.str.r42:():().[nt]

Output

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

Java 8, 157 bytes.

Prints HELLO.

{ppt)i6s;ia.r eapxirf uw le([)i7{pt{7cdwo.,6aov viSjtrowbaor}avn6tS .imD,an}rtsia)eoerttt lt9((.eao[ut,E_tF9t7ge,e ejO.cbm}neiuiie7uiwFt2ri.ihc]no]cnys eanlc
\$\endgroup\$
1
\$\begingroup\$

Python 2, size 13 (Cracked)

Code

ex00123679///

Output

0.0068493150684931503

Original Source

6e1//073/0x92

\$\endgroup\$
3
  • \$\begingroup\$ Edited to make heading formatted \$\endgroup\$
    – mbomb007
    Jan 2, 2015 at 22:12
  • \$\begingroup\$ I used repl.it \$\endgroup\$
    – mbomb007
    Jan 2, 2015 at 22:14
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Jan 4, 2015 at 15:55
1
\$\begingroup\$

Ruby, 65 chars.

code:

  #think(((((())))))*++---./;;==^^^eeeeeeiiiiiimpssttu{|||}112569

(it begins with two spaces)

output:

3
-7
-3
-3
-5
-4

(the output is separated by a new line)

This one shouldn't be too difficult.

Hint:

This one relies heavily on bitwise operators, expecially or and xor

Hint 2:

Some of the parentheses are optional, not really required and are used only to confuse the "Robbers".

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

PHP, 484 chars

s{9$_aer{cmnef]3o"{hmotee]e)=o(mdo/_o sf[di=_{yi(e]9i/lho_o${n}"lt!og]bnek"}[.ec$ [""kebe=-r7")}.0l} ]e]"oe "$3{]$c_)ln$[tee{u;r$cr "cln{e$du{$eodo+(eoc"]d$ocrcd]o e }0o}ll{oo)}no;{2tud;el#o.c $$0d dne{na[[ip2lcerihol dlH}+le [e [;l);[_"]d\.[]c$;n3d(]2$$:hitn"5d.i/tcepm["}noe "el[;;ex}Wx}}e"pe2o  d ,<m)t<tt;l{p$ih$ld$l \ cbye$ +1pi}[c]o l$c$ c"]$"(to}teue$d(]}l{[1e[d"}{)[e+ {e$$?il{">l nheb$)c$.ssbc\nusem;u$lpd=od)in {olsbnn{;}d76oy4sfc}}eicsd]i}xti$=f"ei{(o l$n(;hc :coce dats(ei

output:

hello world

Hint:

The code is NOT platform dependent (tested in os x and ubuntu), although it won't work in ideone or any other online IDE.

Hint 2:

This code generates code in another language and executes it.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You realize this is code golf, right? The goal is to have a short program. \$\endgroup\$
    – mbomb007
    Jan 12, 2015 at 16:17
  • \$\begingroup\$ I wanted to do something challenging and difficult to "crack". \$\endgroup\$ Jan 12, 2015 at 18:49
1
\$\begingroup\$

Javascript - 10 (Cracked)

Scrambled Code

foeblast()

Output

W29iamVjdCBXaW5kb3dd

Answer

btoa(self)

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

Python, size 30 [SAFE]

This one is just for fun, since my last one wasn't solved. :D
This one also has removed the workaround that squeamish ossifrage cleverly found. >:D
Still using http://repl.it/

Scrambled

:: rsin[~rot13(`0ddf`) + 69][]

Output

=> 'rot13'

Original Source

str(d for d in[])[9:6:~0]+`13`
I actually found this by accident. It creates a string of '<generator object <genexpr> at 0x221164>' (or some other address), then uses the rot at the end of generator and appends 13 to it.

Just to be more clear that the '=>' isn't part of the string

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

Insomnia, 14 (Cracked)

Code

(Only 1 space, as seen below)

yes|grep-99 ii

Output

101291340129

Interpreter

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

Keg, length 7

Just for the fun of it.

5|(2&9)

Expected output:

2 5 2 2 2 2 2 2 2 

Since new cop solutions are disallowed, I will just leak the answer: 5(9|&2)

\$\endgroup\$
1
5
6
7 8 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.