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
    Commented Nov 4, 2014 at 20:00
  • 3
    \$\begingroup\$ You might want to forbid hashing... codegolf.stackexchange.com/questions/40304/… \$\endgroup\$ Commented 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\$ Commented 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
    Commented 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
    Commented Nov 6, 2014 at 4:48

245 Answers 245

1 2 3
4
5
9
2
\$\begingroup\$

Mathematica, 18 (Cracked)

Code

!!#&,-./02>@D[]ddd

Output

-EulerGamma + Log[2]
\$\endgroup\$
1
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\$
2
  • \$\begingroup\$ cracked \$\endgroup\$
    – lynn
    Commented Nov 7, 2014 at 19:56
  • \$\begingroup\$ @nooodl Aww, all that work with heredocs for nothing. :) \$\endgroup\$
    – Doorknob
    Commented Nov 7, 2014 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\$
1
2
\$\begingroup\$

C, 53 bytes [Cracked]

Code

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

Output

58980
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – grc
    Commented Nov 8, 2014 at 1:10
2
\$\begingroup\$

Python 2, 29 bytes (cracked)

(.;i;=)de mnoprrrsssssssttyyy

No output.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$
    – xnor
    Commented Nov 4, 2014 at 22:52
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
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – bwoebi
    Commented Nov 5, 2014 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\$
1
  • 4
    \$\begingroup\$ Cracked. Finally. \$\endgroup\$
    – Geobits
    Commented Nov 8, 2014 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
  • 1
    \$\begingroup\$ Cracked. I have to say, this was one of the more fun ones to tackle. :) \$\endgroup\$ Commented Nov 9, 2014 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\$
1
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\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – feersum
    Commented Nov 11, 2014 at 13:51
2
\$\begingroup\$

Perl 5, size 27 (cracked)

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

Output:

ohm

Works under use strict.

\$\endgroup\$
1
  • \$\begingroup\$ cracked by Wumpus Q. Wumbley print'pin'=~tr(a-za)(za-z)r \$\endgroup\$
    – hmatt1
    Commented Nov 6, 2014 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\$
2
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – kennytm
    Commented Nov 12, 2014 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\$ Commented Nov 13, 2014 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\$
5
  • 1
    \$\begingroup\$ Please indicate the version of Python (unless you have tested on both versions and it works on both). This seems like Python 2, since there is a trailing L. \$\endgroup\$ Commented Nov 14, 2014 at 18:21
  • \$\begingroup\$ Sorry. I updated the header. \$\endgroup\$ Commented Nov 14, 2014 at 19:20
  • \$\begingroup\$ Cracked \$\endgroup\$ Commented Nov 14, 2014 at 19:33
  • 1
    \$\begingroup\$ The output should be no more than 100 characters long... \$\endgroup\$
    – r3mainer
    Commented Nov 14, 2014 at 19:41
  • \$\begingroup\$ Oops! Mea Culpa. My apologies. \$\endgroup\$ Commented Nov 14, 2014 at 19:43
2
\$\begingroup\$

Mathematica, 31

Code

PowerMod[123456789,123456789,^]

Output

1617298209804017979868926932743750272386265163887231542207613855504645035580118031906932144113367511
\$\endgroup\$
5
  • \$\begingroup\$ (Inspired by xnor's Python cops a few submissions above) \$\endgroup\$
    – jcai
    Commented Nov 16, 2014 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\$ Commented Nov 17, 2014 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
    Commented Nov 17, 2014 at 5:17
  • \$\begingroup\$ I must have miscounted, then. I got 101 when I fed it into wc -c. \$\endgroup\$ Commented Nov 19, 2014 at 23:25
  • \$\begingroup\$ @AlexVanLiew It is not easy to feed into wc -c directly without the trailing newline. \$\endgroup\$
    – jimmy23013
    Commented Nov 20, 2014 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\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Commented Nov 16, 2014 at 0:49
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\$
0
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\$
2
  • \$\begingroup\$ Cracked \$\endgroup\$
    – histocrat
    Commented Nov 19, 2014 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
    Commented Jan 6, 2015 at 21:02
2
\$\begingroup\$

Golfscript - 20 (Cracked)

"open world thrill!"

Output

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

Lua 5.2.3, Size: 18 chars (Cracked)

pghmint(rat.hue)<3

Output:

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

Python, 28 (Cracked)

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

Output: 100220321420320200100

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – r3mainer
    Commented Nov 24, 2014 at 23:45
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\$
7
  • \$\begingroup\$ Agh, it's been too long! And I don't have my calculator with me. Have a +1. \$\endgroup\$
    – DLosc
    Commented Nov 15, 2014 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
    Commented Nov 24, 2014 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
    Commented Nov 25, 2014 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
    Commented Nov 27, 2014 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
    Commented Nov 27, 2014 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\$
2
  • \$\begingroup\$ is there a newline at the end of the output? \$\endgroup\$ Commented Nov 7, 2014 at 22:56
  • \$\begingroup\$ Nope, there isn't. Note the final ; though. \$\endgroup\$
    – lynn
    Commented Nov 8, 2014 at 0:14
2
\$\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\$
3
  • \$\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
    Commented Dec 6, 2014 at 0:19
  • \$\begingroup\$ Are there interpreters/emulators or documentation for this language available online? \$\endgroup\$ Commented Dec 6, 2014 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
    Commented Dec 7, 2014 at 18:17
2
\$\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\$
2
\$\begingroup\$

Rust + Clojure, version 2 [SAFE]

This is the second version of the task. The first version is here.

Output, without the newline:

1283691742071510101818513212188161611241111219191910762714142222223591109301717171051225

There is a hint (the same as in version 1):

tr/gio_.ocupkzwwaaeeeeiiC/.ojdtkrnnlliic

Now the task is more related to the hint compared to version 1. The algorithm is the same in Rust and Clojure versions, there are no comments, unused identifiers thow-away assignments. All identifier have 1-character names.

Rust, 118 characters

====>        -,,:!/""((((((())))))){{{{{{{}}}}}}}*%+++001111112235aaeeeeefffffgiiiiiiiiillmnnnnnnnnoprrrrrrrrsstttxxxx

Clojure, 106 characters

==                /(((((((((((((((())))))))))))))))[[]]*++00011112235adddeeefffgiiiiimnnnoopqrrrrrrrstxxxx

C, 128 characters

<=====       ,;;;;;;;/""((((((((())))))))){{}}*%%+++++001111112235adeeeffffiiiiiiiiiiiiimnnnnnnnnnoprrrrrrrrrrrrrttttttttuuuxxxx

Haskell, 83 characters

======||      _;;....((()))[]$*+++011111122349aaddehiimmmMnoopprrrrrrsSttTuuvwxxxxx

Perl, 97 characters

=====   ;;/..(((((()))))){{{{{}}}}}$$$$$$$*%+++011111122349beeeffffhiiiiiillnoprrrrrrrssssttuxxxx

Shell, 170 characters

````````==                                 ;;;;;;;;;/((((((((((()))))))))))[[]]{}$$$$$$$$$$*%+++0111111111122349cccddeeeeeeeeeefffffhhhhhiiiiiiillnnnnnoooooopqrrrrrrssttt

Checked with dash, bash, ksh a zsh.

Original source codes

⚠Note: without >! spolier marks.⚠



    (the code is immediately visible below)





⚠Note: without >! spolier marks.⚠

Rust

(does not work anymore with modern Rust)

fn x(r:int)->int{if r==1{1}else if r%2==0{x(r/2)+1}else{x(3*r+1)+1}}fn main(){for i in range(1,50){print!("{}",x(i))}}

C

int x(int r){if(r==1)return 1;if(r%2==0)return x(r/2)+1;return x(3*r+1)+1;}int main(){int i;for(i=1;i<50;++i)printf("%d",x(i));}

Perl

int x(int r){if(r==1)return 1;if(r%2==0)return x(r/2)+1;return x(3*r+1)+1;}int main(){int i;for(i=1;i<50;++i)printf("%d",x(i));}

Clojure

(defn x[r](+ 1(if(= r 1)0(if(=(mod r 2)0)(x (/ r 2))(x (+(* 3 r)1))))))(doseq[i(range 1 50)](print (x i)))

Shell

r(){ if [ $1 = 1 ]; then echo 1; elif [ $(($1%2)) = 0 ]; then echo $((1+`r $(($1/2))`));else echo $((1+`r $(($1*3+1))`));fi;}; for i in `seq 1 49`; do printf `r $i`; done

Haskell

x 1=1;x r|mod r 2==0=1+x(div r 2)|True=1+(x$3*r+1);main=mapM_(putStr.show.x)[1..49]

Hint

echo 'http://en.wikipedia.org/wiki/Collatz_conjecture' | perl -pe 's//\n/g' | sort -R | tr -d '\n'; echo

Characteres were manually moved around to make it appear like a character substitution command, which is a red herring.

Explanation

Here is readable modern Rust code:

fn x(r: i32) -> i32 {
    if r == 1 {
        1
    } else if r % 2 == 0 {
        x(r / 2) + 1
    } else {
        x(3 * r + 1) + 1
    }
}
fn main() {
    for i in 1..50 {
        print!("{}", x(i))
    }
}

It prints 50 elements of https://oeis.org/A008908 glued together. Algorithm is the same for all languages.

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

Python - 37

mr79ltmo22mat51p*h(* .ian tpihgt)or()

(NB: there are exactly two trailing spaces)

This is both easy and hard at the same time.

This program

+Returns 1975

+Does not error or throw any warings

+Uses all of the characters (no print(1975) for you)

As a bonus challenge:

(t.nmm)t(= (ihn ))tttu*oaniiorm(tignp2hlpa) npr * 2

(NB2: trailing space)

This takes in a number n as input and returns it, with no errors/unused characters.

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

CJam, 18 (Cracked)

Code

012234567889""**%~

Output

444
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Commented Nov 4, 2014 at 22:53
1
\$\begingroup\$

CJam, Size 12

Cracked by user23013

!mop[ET_^~+1]

Output

-214

My first ever CJam program. :)

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Commented Nov 5, 2014 at 4:00
1 2 3
4
5
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.