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

5
\$\begingroup\$

JavaScript, 73

Code

console.log((((((('[[.....=-,,]]'+'02aaceeeeeefiiijllopprrrrssttv')))))))

Output

denied
\$\endgroup\$
5
\$\begingroup\$

Python 3, size 44 [cracked by feersum]

Scrambled:

print(((((((((((((()))))))))))))),,<<<<<<<~~

Output:

3

I'm trying to make Python look more like LISP.


Explanation

This one relies on Python's use of implicit conversion. ()<((),) evaluates to True, and applying << [bitshift] implicitly converts True to 1.

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – feersum Nov 5 '14 at 13:46
  • 1
    \$\begingroup\$ @feersum Fast :P \$\endgroup\$ – Sp3000 Nov 5 '14 at 13:47
5
\$\begingroup\$

GolfScript, 20 bytes [safe]

Code

...[[]]{{}}&%%++++5i

Output

32

Output does not have a newline character in the end.

Inspired by this comment.

Solution

.{5i[+]+}.%{}++[.%]&

\$\endgroup\$
5
\$\begingroup\$

CJam, 19 (Cracked)

Code

JJ2334567899#%**~""

Output

500827930823087774653348
\$\endgroup\$
5
\$\begingroup\$

Grass, size 134 [safe]

Code

WWWWwwWwWwWWWwWWWWwwwWwWwwwWwwwwwWWwWwwWwWWwWwwWWwwwwWwwwwWwwwWWwwwWwwwWWwwwWWWWWWWWwwWWwwwWwWWWWWwWWWwWWwwwwWWWwwWWwwwWwWWWwWwwwWWWWW

Output

wwwwwwwwwwwwwww

Tested in the Python interpreter.

Solution

wWWWwwwwWwwwwwWwWwwwwwWwwwwwwwwWWwWWWwWWWWwWWWWWWwwwwwwWwwwwwwWwwwWWwWWWwWWWWwWWWWWWwwwwwwWwwwwwwWwwwWWwWWWwWWWWwWWWWWwWWWWWWwWWWWWWWw

I wonder if anyone has tried...

\$\endgroup\$
  • \$\begingroup\$ This is straight up cruel. Good job. \$\endgroup\$ – Alex Van Liew Nov 14 '14 at 19:07
  • \$\begingroup\$ Your program is safe now. You should post your code to protect your submission. \$\endgroup\$ – Hosch250 Nov 20 '14 at 5:49
5
\$\begingroup\$

Python 2 - 61 Cracked

Code

r~s]l][]:.c[():sit_'3-'(pt_trp.l]2-~n:][.i':o:p0Te[d_u1[.')i_

Output

get

Original

print''.__doc__[::2][::3].split()[1].split('.')[0][:-~-~True]

\$\endgroup\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – grc Nov 5 '14 at 3:27
  • \$\begingroup\$ Outputs s> in Python 3.4 \$\endgroup\$ – CoDEmanX Nov 10 '14 at 11:23
  • \$\begingroup\$ @CoDEmanX Yes, I wouldn't expect this to work in Python 3, which is why I specified Python 2. \$\endgroup\$ – FryAmTheEggman Nov 10 '14 at 13:36
4
\$\begingroup\$

PHP, size 23 [Cracked]

Code

echo@$b=$b.$c,$c=$c.$c;

Output

bbbbb
\$\endgroup\$
  • \$\begingroup\$ Ah, that was unfortunate. I've got it now, but I can't submit again. \$\endgroup\$ – Martin Ender Nov 5 '14 at 15:53
  • \$\begingroup\$ @MartinBüttner How did you then get it now? (Do you even know why it works?) \$\endgroup\$ – bwoebi Nov 5 '14 at 15:55
  • \$\begingroup\$ well I just got it by experimenting a bit more. I don't get what I need the @ for, I have no idea why concatenating undefined constants work and I wasn't aware that you could have more than one $ in a variable name, but otherwise, it's pretty clear. ;) \$\endgroup\$ – Martin Ender Nov 5 '14 at 15:56
  • \$\begingroup\$ @MartinBüttner the @ is just for avoiding notices. I wonder if there was another solution than my original, so I asked. \$\endgroup\$ – bwoebi Nov 5 '14 at 15:58
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$ – jimmy23013 Nov 5 '14 at 17:51
4
\$\begingroup\$

JavaScript, length 32 (cracked)

alert('HaVobp'.match(/[HaVt]+/))

Output

puGiXm
\$\endgroup\$
4
\$\begingroup\$

CJam, size 19 (Cracked)

Code

"Can't touch this!"

Output

hunt 12tacos

(Probably not as difficult as the last one, but I had to post a sequel.)

\$\endgroup\$
  • \$\begingroup\$ It's taco season - Elmer Fudd \$\endgroup\$ – FryAmTheEggman Nov 6 '14 at 15:42
  • \$\begingroup\$ Cracked. \$\endgroup\$ – jimmy23013 Nov 6 '14 at 15:47
4
\$\begingroup\$

Golfscript, 32

Code

  *++..0011125::::;;;?bbbbcccc{}

Output

1993841993677373809355710590420516863199384199367737380935571059042051686311
\$\endgroup\$
4
\$\begingroup\$

C, 70 (Cracked)

Code

C='g'-pf;main(hx){ok,the(hot)Cake isA lie;forC*-g.=+:;prntf("%d",40);}

Output

40135

Original Solution

main(h,r){float C=h;ek:C+=0xA.ep4;if(h--)goto ek;printf("%g",C*'sd');}

\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – feersum Nov 6 '14 at 6:28
4
\$\begingroup\$

CJam, 34 bytes (cracked)

Scrambled source

""Beware the Jabberwock, my son!""

Output

1.0245778622239579
\$\endgroup\$
  • \$\begingroup\$ Guessing its the same concept as Martin's \$\endgroup\$ – Optimizer Nov 6 '14 at 17:07
  • \$\begingroup\$ @Optimizer: Certainly inspired by it, but hopefully much more difficult to unscramble. \$\endgroup\$ – Dennis Nov 6 '14 at 17:08
  • 1
    \$\begingroup\$ The jaws that bite, the claws that catch! \$\endgroup\$ – Doorknob Nov 6 '14 at 18:50
  • 2
    \$\begingroup\$ Cracked, with Martin's idea. \$\endgroup\$ – jimmy23013 Nov 8 '14 at 10:16
4
\$\begingroup\$

Ruby, 35

Code

}||{yyssplliihhddaa____][>====:.-)(

Output

shadilyshadily
\$\endgroup\$
  • 3
    \$\begingroup\$ Methinks the scrambled code should have ended with >:-) \$\endgroup\$ – DLosc Nov 12 '14 at 2:07
  • \$\begingroup\$ Cracked. \$\endgroup\$ – Martin Ender Nov 12 '14 at 11:48
4
\$\begingroup\$

JavaScript, 69 Cracked by FireFly

Code

grr('action rat')''(((())))*++++00001122333355566677====S[[]]ffffffxx

Output

"nananananananananananana batman"

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

\$\endgroup\$
  • \$\begingroup\$ @MartinBüttner Shoot, you are absolutely right (fixed) \$\endgroup\$ – SLuck49 Nov 12 '14 at 20:15
  • \$\begingroup\$ Cracked. \$\endgroup\$ – FireFly Nov 14 '14 at 20:18
4
\$\begingroup\$

Ruby, 43

Code

*+89*:%t(|in set{2e0--1e2}|*.prime?<~1)(25)

Output

11010100010100010100010000010100000100010100010000010000010100000100010100000100010000010000000100

Hint

The scrambled code (after the first few characters) describes the output. For each number in the set of natural numbers between 2e0 and 1e2 (2 to 100), output a 1 if it's prime and a 0 otherwise, for 25 primes in total.

Original Code

98.times{|e|print (2**e*~-5-1)%(e+2)<2?1:0}

Explanation

I learned this trick from leonid's answer on an Anarchy Golf problem. The code doesn't actually do a valid prime check, it uses the Fermat Primality Test in base 2, which is probabilistic but is correct up to 341 or so.

\$\endgroup\$
4
\$\begingroup\$

C++11, size 104 [safe]

Code

<<<<<<==>>  ,,,,,,;;:::::?.""(){}\&&##07aabcccccddddddeeeeehiiiiillllllmmnnnnooorrsssssttttttttttuuuux

And two newlines.

Compiled with g++ --std=c++11.

Output

hello
hello
hello
hello
hello
hello
hello
hello
hello
hello

I thought I should have printed something better than hello.

Solution

#include<iostream>#\><

struct u{int t=std::cout<<"hello"<<std::endl&&7;}l,d,s,c,b,main=d.t?exit(0),l:c;

Someone please explain how it works to me...

\$\endgroup\$
  • 1
    \$\begingroup\$ I tried this one; I was unable to find the answer, but it inspired me to write this C program: #include <stdio.h> main(x) { bsearch("hello\n", &x, 1000, 1, printf); } \$\endgroup\$ – feersum Nov 9 '14 at 16:56
  • \$\begingroup\$ Is there a trailing newline? \$\endgroup\$ – Mike Precup Nov 13 '14 at 0:10
  • \$\begingroup\$ @MikePrecup Yes. \$\endgroup\$ – jimmy23013 Nov 13 '14 at 0:12
4
\$\begingroup\$

PHP, 53 (Cracked)

Code

o3o5do=++,"oodr=f(+$fni9$d;$9=d9$$%rp7<o$t=$);$,")5(;

Output

571349220413226117734422843528553434864141775449210755731225661136475615328581707
\$\endgroup\$
4
\$\begingroup\$

PowerShell 182 [safe]

but definitely not the winner

''-join%{[char]};;|$()$a$a$a$c$c$c$_===+;    0-82,-82,-75,-70,-68,-68,-65,-15,-11,-11,-11,-11,-9,-7,-7,-7,-6,-6,-6,-2,-1,-1,0,1,1,7,8,8,8,11,13,13,13,15,21,25,48,65,79,80,80,80,80,80

Output

Peter Piper picked a peck of pickled peppers

Solution

$a = 0;$(80,21,15,-15,13,-82,48,25,7,-11,13,-82,80,-7,-6,8,-6,-1,-68,65,-65,80,-11,-2,8,-75,79,-9,-70,80,-7,-6,8,1,-7,-1,-68,80,-11,11,0,-11,13,1|%{$c=$a+$_;$a=$c;[char]$c}) -join ''
\$\endgroup\$
  • \$\begingroup\$ You program is safe now. You should post your code to protect your answer. \$\endgroup\$ – Hosch250 Nov 20 '14 at 5:49
4
\$\begingroup\$

JavaScript, 79 bytes [safe]

Another one, for fun. Might be similar to Shawn's 69 (at least I got the idea while working on it and not succeeding). Outputs using alert, which is already unscrambled for your convenience.

Code

alert(0123)
//((((()))))++...3566777===[[[\]]]
//accefffgggghhhhiiklmnnoorrstuw

Output

underhanded

Hint

Here's a hint: think of substitution ciphers.

Solution

for(f
in(g=/56732106737/.source+(h=[])))h+=g.link().match(/\w/g)[g[f]]
alert(h)

The digits in the regex pattern correspond to indices in the string g.link() aka <a href="undefined">56732106737</a>. "underhanded" uses only characters reachable by indexing with single-digit numbers into this string (most from "undefined").

\$\endgroup\$
4
\$\begingroup\$

JavaScript, 31 bytes (SAFE)

Code

'([(102)])prenatal.gecko'tonsil

Output

j

Should work in any browser console, although it is a standalone program.

Original source

alert('0acegnos'.link(top)[12])
The characters in the string are red herring, so it wouldn't be obvious what functions were used. It uses the little-known link function, which makes an HTML <a> element. The top object is converted to a string as [object Window], and added as the <a> link, the twelfth character of which is j.

\$\endgroup\$
  • 1
    \$\begingroup\$ Just double-checking, is the code missing a third o by any chance? \$\endgroup\$ – Martin Ender Jan 4 '15 at 14:08
  • \$\begingroup\$ @MartinBüttner No it's not. \$\endgroup\$ – NinjaBearMonkey Jan 4 '15 at 16:08
  • \$\begingroup\$ Very clever... maybe try for a shorter one now? \$\endgroup\$ – mbomb007 Jan 12 '15 at 19:05
4
\$\begingroup\$

Perl - 26 bytes (cracked by choroba)

p:rlq{not goto p,if$a>=$b}

Output

potato
\$\endgroup\$
3
\$\begingroup\$

CJam, size 15 (Cracked)

Code

6789%%%++:,{{}}

Output

882
\$\endgroup\$
3
\$\begingroup\$

Coffeescript - 96

There might be more than one way to solve this one. It's also pretty long, but hopefully it will survive cracking for a while.

Output:

5299944725070263763912242111215369742359896456157909233296841284031194827848086

Program characters: (note \n is a newline and \s is a space):

j\n][j9\sa='';]4j90].[.[i\n1].=iaa[]e]9i[9\sa]\s9t][ia2]n.8v\nan.fa=ar%,i\s1%=l+o.\s[09[j],+v%[\sroj,[9i.

Or without \n and \s:

j
][j9 a='';]4j90].[.[i
1].=iaa[]e]9i[9 a] 9t][ia2]n.8v
an.fa=ar%,i 1%=l+o. [09[j],+v%[ roj,[9i.
\$\endgroup\$
  • \$\begingroup\$ In the scrambled code, I accidentally put a 2 instead of a 4... sorry about that. It's fixed now. \$\endgroup\$ – soktinpk Nov 5 '14 at 2:36
  • 1
    \$\begingroup\$ I'm pretty sure it's impossible to crack some of these submissions with more than 50 characters. \$\endgroup\$ – soktinpk Nov 9 '14 at 22:26
3
\$\begingroup\$

CJam, size 52 (cracked)

Code

,,,,,;::::'""))@*\&%+++++333333333333333333ccffffffm

Output

0!1"2#3$4%5&6'7(8)9*10+11,12-13.14/15016117218319420521622723824925:26;27<28=29>30?31@32A
\$\endgroup\$
3
\$\begingroup\$

Java - 70 bytes

.;{({([(pentagrams are cool)])})};. Sivintilituscimt Spunsimtsbuncyndt

output:

s

no quotation marks? What sorcery is this???

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – feersum Nov 7 '14 at 6:17
3
\$\begingroup\$

C, 51 (cracked)

Code

f;main(h,taxgpl) {for(c=90;c;c++) printf("%.d",h);}

Output

8065

Original Solution

main(h,dr){float c=+h+0xf.cp9;;; printf("%g",(c));}

\$\endgroup\$
  • \$\begingroup\$ cracked \$\endgroup\$ – Art Nov 7 '14 at 12:36
  • \$\begingroup\$ @Art congratulations! \$\endgroup\$ – es1024 Nov 7 '14 at 22:32
  • \$\begingroup\$ I was trying to abuse argc being 1, but I hacked up my solution on a machine with clang and it refuses to accept non-standard definitions of main. It was a neat puzzle. I almost gave up after I spent two hours trying to do something like c=0xfbc; .. printf("%d", c + c + 9); but there was no "b". Was that on purpose? If so, it was a great tarpit. \$\endgroup\$ – Art Nov 8 '14 at 10:09
3
\$\begingroup\$

C++, 192 chars (Cracked)

Code

#include<stdio.h>
#define d double
(){return ;}(){return ;}int main(){printf("%.15f",));}       %(((((()))))****,,,,,,,,,,,-----..///000011122234477777::>??dddddfffggggiiiiiiiiiiinnttxxxxxxyyy

Output

3.141592653589793
\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – feersum Nov 8 '14 at 13:58
3
\$\begingroup\$

QBasic, 42 bytes (Cracked)

I am having way too much fun here.

Code:

FAIR
N=PATERN"QBasic!"TIME 2 OR 1+1
HOUT N

... including 2 newlines. (This is written in a new dialect of QBasic that allows you to use nonstandard English, redundancy, and misspelled keywords as long as you tell the compiler that it's all FAIR.)

Output:

QBasic!
QBasic!

... including a trailing newline.

\$\endgroup\$
3
\$\begingroup\$

JavaScript, 46 characters [Cracked]

This one is easy, so I expect it to be cracked quickly.

Code

//terser code..
alert(the union fears dwarves)

(includes newline)

Output

ordered
\$\endgroup\$
3
\$\begingroup\$

JavaScript, 28 Cracked by Martin Büttner

Since my other submission was cracked, here's another.

Code

eval(atob('[every thing]'));

Output

1

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

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