141
\$\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
  • 60
    \$\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

240 Answers 240

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

Python, 45

Code:

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

Output:

0

Original

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

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Sp3000 Nov 13 '14 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\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – es1024 Nov 16 '14 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\$
  • \$\begingroup\$ Works in both versions? \$\endgroup\$ – Martin Ender Nov 11 '14 at 8:22
  • \$\begingroup\$ Just double checking - exactly one comma? \$\endgroup\$ – Sp3000 Nov 11 '14 at 8:46
  • \$\begingroup\$ @MartinBüttner Yes, should work on any version (tested with 2.7 and 3.3). \$\endgroup\$ – DLosc Nov 11 '14 at 19:45
  • \$\begingroup\$ @Sp3000 Exactly one. :) \$\endgroup\$ – DLosc Nov 11 '14 at 19:47
  • \$\begingroup\$ Good old exec, the [:] did well to confuse. \$\endgroup\$ – Sp3000 Nov 18 '14 at 23:48
1
\$\begingroup\$

Javascript size 13 (Cracked)

Going for the shortest, runs on shell

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

Output

"0"
\$\endgroup\$
  • 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 '14 at 22:06
  • \$\begingroup\$ @Dennis Both of them go into shells, I split them up. \$\endgroup\$ – Caridorc Nov 4 '14 at 22:08
  • 3
    \$\begingroup\$ I count 13 characters. (And cracked it.) \$\endgroup\$ – Martin Ender Nov 4 '14 at 22:14
1
\$\begingroup\$

Python, 68 (Cracked)

Code

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

Output

#123456789
\$\endgroup\$
  • \$\begingroup\$ Cracked - Think this should be the intended solution, or something similar at least \$\endgroup\$ – Sp3000 Nov 5 '14 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\$
  • \$\begingroup\$ Cracked! \$\endgroup\$ – squeamish ossifrage Nov 5 '14 at 1:04
  • \$\begingroup\$ Vi.?󠀠󠀠󠀠󠀠󠀠󠀠󠀠 \$\endgroup\$ – Vi. Nov 14 '14 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\$
  • \$\begingroup\$ Does this have a print statement included or is it supposed to be run in a shell? \$\endgroup\$ – NinjaBearMonkey Nov 5 '14 at 4:27
  • \$\begingroup\$ Run in a shell. No print statement. \$\endgroup\$ – Kyle Gullion Nov 5 '14 at 4:29
  • \$\begingroup\$ Solved. \$\endgroup\$ – NinjaBearMonkey Nov 5 '14 at 4:33
  • \$\begingroup\$ That works. Forgot about that pesky 'a'. \$\endgroup\$ – Kyle Gullion Nov 5 '14 at 4:37
1
\$\begingroup\$

Perl, 39 (Cracked)

Code

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

Output

H

Tested here

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

ECMAScript, 29 (Cracked)

Code

1("HAlf PEnCesEveNthswunG".5)

Output

32768
\$\endgroup\$
  • \$\begingroup\$ Both this and your other submission seem to require a console/REPL environment, and are not full programs. \$\endgroup\$ – Martin Ender Nov 5 '14 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 '14 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\$ – Martin Ender Nov 5 '14 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 '14 at 12:57
  • \$\begingroup\$ Cracked. \$\endgroup\$ – Martin Ender Nov 6 '14 at 13:03
1
\$\begingroup\$

Mathematica, 35 characters (Cracked)

Code

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

Output

0
\$\endgroup\$
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\$
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\$
  • \$\begingroup\$ I lol'd at swapping cstdlib for cstdint \$\endgroup\$ – Patrick Purcell Nov 27 '14 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\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – DLosc Nov 25 '14 at 18:11
1
\$\begingroup\$

JavaScript, 36

scrambled code:

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

output: ion

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

RPL (HP48), 10 characters (safe)

I thought RPL was out of the question, as discussed in my first and my second (deleted) submission. However, instead of creating a program object (with code enclosed in « », and possibly store it), I can just type the RPL code without « » and press Enter to execute the code immediately (kind of command line).

For example, instead of creating the program « 1 2 3 + », I can just enter 1 2 3 + for immediate execution, and the output (addition to the stack) will be:

1
5

Now to the actual (reworked) puzzle that actually follows the rules. Because previous one did not follow the rules, the time for it starts now. (Unfortunately I can't post the other reworked puzzle now because I had already supplied the answer.)

Code (to be entered for immediate execution):

"DO PURGE"

No output (no change on the stack), also no error.

Edit: I'm sure I've given enough time since helping with emulator information and documentation. So I'm now claiming immunity by posting the solution:

"GUE" DROP

Words DO and PURGE are the actual commands and I chose them because they deceive but provide the characters needed. PURGE will cause an error unless there is a name of an existing variable on the stack. Even if that's satisfied and the name is then taken off the stack, how will you get rid of ""? And how will you put a variable name on the stack without ''? It works if the variable doesn't exist, otherwise it gets evaluated. Of course, the behaviour would then depend on other factors, which should not be the case with any code in this contest. DO is for loops and would be incomplete, therefore cause an error (either run-time or syntax).

\$\endgroup\$
  • \$\begingroup\$ It's been about 8 1/2 days without any attempt being posted. In fact, for the last 10 days there have been no robber attempts at all. Is that the end of this pair of threads (and the contest)? I'm thinking whether I should post the solution and claim immunity as it doesn't feel like much of a win in complete absence of robbers... Also, this submission is not mentioned in the list of unsolved ones - does that still count? \$\endgroup\$ – Heimdall Dec 6 '14 at 0:19
  • \$\begingroup\$ Are there interpreters/emulators or documentation for this language available online? \$\endgroup\$ – algorithmshark Dec 6 '14 at 5:40
  • \$\begingroup\$ Yes, @algorithmshark. I've seen the emulator on Linux, I've got the Android one, there's plenty to find by searching "hp48 emulator". I'm pretty sure it's available for all major platforms. Here's the manual straight from the horse's mouth. Should I (with the spirit of this contest) extend my immunity claim to give people a proper chance as I have only just offered help with this comment? \$\endgroup\$ – Heimdall Dec 7 '14 at 18:17
1
\$\begingroup\$

Assembly, 78 bytes, bootloader x86, GAS

0$0y
v,
:eylo1c1
e0.d
xxx
1+m
i$dt1ev 5.$on ,xe%a
.bt tb05=6d axa0.mh6a 50%
o0

output:

a

solution:

.code16
d:
mov $0x61,%al
mov $0xe,%ah
int $0x10
.=d+510
.byte 0x55
.byte 0xaa

\$\endgroup\$
  • 2
    \$\begingroup\$ At least you were kind enough to scramble the assembly, and not the machine code. :P \$\endgroup\$ – FireFly Nov 19 '14 at 19:07
  • \$\begingroup\$ How do you set bl? I lack either a b or a , \$\endgroup\$ – mirabilos Dec 23 '14 at 14:19
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
\$\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\$
  • \$\begingroup\$ Edited to make heading formatted \$\endgroup\$ – mbomb007 Jan 2 '15 at 22:12
  • \$\begingroup\$ I used repl.it \$\endgroup\$ – mbomb007 Jan 2 '15 at 22:14
  • \$\begingroup\$ Cracked. \$\endgroup\$ – jimmy23013 Jan 4 '15 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\$
  • 1
    \$\begingroup\$ You realize this is code golf, right? The goal is to have a short program. \$\endgroup\$ – mbomb007 Jan 12 '15 at 16:17
  • \$\begingroup\$ I wanted to do something challenging and difficult to "crack". \$\endgroup\$ – user3807877 Jan 12 '15 at 18:49
1
\$\begingroup\$

Python 2, size 23 [SAFE]

Using http://repl.it/

Scrambled

-/*[st0r3:.1245689])(()

Output

'110665.1105651'

Original Code

(str(065/.814)*2)[9:-3]
This takes the octal value 065 and divides it by .814 to create a longer decimal value. I then converted that to a string and repeated it twice by using *2. The final part takes a substring of that result, making it harder to know what went on.

\$\endgroup\$
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\$
0
\$\begingroup\$

Befunge-93, size 17 (cracked)

Code

>_-,/""@
*#%+69pv

Output

@

Looks like it has probably used some non-standard feature of this interpreter.

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