44
\$\begingroup\$

This is the companion thread to the main Unscramble the Source Code challenge. If you think you have managed to unscramble one of the cop answers, you should post your solution as the answer to this thread.

As a reminder, 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.

Leaderboard

Too many solves

20 solves

15 solves

10 solves

7 solves

5 solves

4 solves

3 solves

2 solves

1 solve

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Perl 5, size 27, by Morot - print'pin'=~tr(a-za)(za-z)r \$\endgroup\$
    – user15244
    Commented Nov 6, 2014 at 14:34
  • \$\begingroup\$ @WumpusQ.Wumbley We've all been there... ;) \$\endgroup\$ Commented Nov 6, 2014 at 14:35
  • 3
    \$\begingroup\$ I refuse to waste my time attempting to appease it. \$\endgroup\$
    – user15244
    Commented Nov 6, 2014 at 14:35
  • \$\begingroup\$ Given the two question bodies, it appears that the scrambled/unscrambled answers are reversed \$\endgroup\$ Commented Nov 6, 2014 at 23:31
  • \$\begingroup\$ Ruby, 23 by MegaTom = p %++.methods[80][1..-1] \$\endgroup\$
    – histocrat
    Commented Nov 11, 2014 at 22:31

182 Answers 182

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

PHP, 33, by kenorb

This one was quite easy:

<?=strlen(highlight_string(0,1));

In case you were wondering, highlight_string(0,1) produces this result (with a total of 52 characters):

<code><span style="color: #000000">
0</span>
</code>
\$\endgroup\$
3
\$\begingroup\$

Bash, size 33, by Debasis

echo shellpower|awk '{print $1}'

Had to ssh into uni to test that...

\$\endgroup\$
1
  • 2
    \$\begingroup\$ I got ${pintwk1ar} |echo 'shellpower' \$\endgroup\$
    – jimmy23013
    Commented Nov 6, 2014 at 23:50
3
\$\begingroup\$

JavaScript, size 10, by Chris

{newa:(1)}

That was finally solvable...

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

SAS, size 17, by user3490

%put%eval(a>1>b);

Simply evaluates the expression a>0>b left to right (giving the results of FALSE, which is represented in SAS by 0) and prints the result to the log.

(Thanks to Sp3000 for noting I originally wrote a>0>b.)

\$\endgroup\$
3
  • \$\begingroup\$ Just formatted the code a tad with the {} button, if you don't mind :) \$\endgroup\$
    – Sp3000
    Commented Nov 7, 2014 at 2:47
  • \$\begingroup\$ Also, the original code has a 1 instead of a 0. Does this change anything or does swapping 0 for 1 still work? \$\endgroup\$
    – Sp3000
    Commented Nov 7, 2014 at 2:56
  • \$\begingroup\$ Whoops, I'll fix that. They both return 0, because of the way SAS evaluates the expression. \$\endgroup\$
    – ConMan
    Commented Nov 7, 2014 at 5:31
3
\$\begingroup\$

Java, size 70, Rodolvertice

enum n{s;public static void main(String[]acl){System.out.print((s));}}

I had no idea how enums even worked, with a default toString() returning their name in the source code and all, but there were so few non-boilerplate characters available that it was easy to discover.

\$\endgroup\$
2
  • \$\begingroup\$ congrats! original used println and a as class name. :) \$\endgroup\$
    – vero
    Commented Nov 7, 2014 at 7:19
  • \$\begingroup\$ @Rodolvertice I didn't use println, because you didn't list a newline as part of the output. \$\endgroup\$
    – feersum
    Commented Nov 7, 2014 at 7:49
3
\$\begingroup\$

Javascript, size 285, by Beta Decay

alert(String.fromCharCode(65,90))//      """"""(((((()))))),,,......../////001111222222333334666677777788999:========AEGHJLLLMNORTTX[]_aaaaaaaaaaaaaaaabbbccdddeeeeeeeeeeeeeeeeffffghhhhiiiiiiiijmmmmnnnnnnnnoooooooooooooopppppqrrrrrrrrrrrrrrssssssssssssssstttttttttttttuuuvvvwwwwxz

and some newlines after that.

\$\endgroup\$
1
  • \$\begingroup\$ Well that's one way :) \$\endgroup\$
    – Beta Decay
    Commented Nov 7, 2014 at 11:36
3
\$\begingroup\$

Ruby, size 33, by Doorknob

puts [?\[+?*+?]]-[$?..$\]*$$.next

I don't know Ruby and have no idea what does $?..$\ really mean. Apparently $? and $\ are the only things having the same type (or both undefined?) which will not throw an error.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ $? is the Process::Status from the last call to Kernel#system. $! is the Exception being rescued. Both are usually nil. Your code makes the Range object nil..nil. \$\endgroup\$
    – kernigh
    Commented Nov 9, 2014 at 23:01
  • \$\begingroup\$ @kernigh It's $\. \$\endgroup\$
    – jimmy23013
    Commented Jan 7, 2015 at 16:37
3
\$\begingroup\$

Python, size 41, by Sp3000

exec("import re\x0Aprint(re.__all__[1])")

Fairly sure this is the intended solution.

\$\endgroup\$
4
  • \$\begingroup\$ I had exactly this! But I thought it was wrong because there were left over rs... apparently I messed up counting this. I don't think this is the intended solution because it only works on Python 2. \$\endgroup\$
    – feersum
    Commented Nov 7, 2014 at 22:09
  • \$\begingroup\$ @feersum: It works in Python 3.3 (as noted in the original posting). It fails in Python 3.4 because they added fullmatch in front of search. \$\endgroup\$
    – nneonneo
    Commented Nov 7, 2014 at 22:59
  • \$\begingroup\$ @feersum This was the intended solution. I thought something like that might happen so I tested in 5 different ways, but unfortunately I forgot about Python 3.4. Sorry about that. \$\endgroup\$
    – Sp3000
    Commented Nov 8, 2014 at 2:08
  • \$\begingroup\$ @Sp3000 At least it gives me a clue about this question... \$\endgroup\$
    – feersum
    Commented Nov 8, 2014 at 2:17
3
\$\begingroup\$

Ruby, size 37, by Rodolvertice

puts 5423187690^2351479806^1523406978

I noticed that the code had exactly three of each digit 0-9, so I guessed the solution would be three numbers that were permutations of 1234567890. Rather than check all of those, I decided to start with numbers of the form 1234500000, xor them, and see if the first 13 bits were correct; if so, then I would fill in the last five digits of each number with a permutation of 67890 and check the final result. The Python 3 script I threw together found this solution within a few seconds.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I guess there could be hundreds of solutions to this type of problem, but my original used an octal... I thought it would make it a lot harder, but it didn't. Original: puts 0741605235^7928381406^1254936789. +1 \$\endgroup\$
    – vero
    Commented Nov 9, 2014 at 3:34
  • \$\begingroup\$ @Rodolvertice Yeah, xor by nature has a lot of possible solutions. Interesting about the octal (and the non-even distribution of digits among the three numbers). \$\endgroup\$
    – DLosc
    Commented Nov 9, 2014 at 5:23
3
\$\begingroup\$

C#, size ~600, eshansingh1

using System;class Program{static void Main(string[]a){Console.WriteLine("Hello, World!");Console.WriteLine("Other World!");

String c=""+""+""+"wwTxRExpphk=   [email protected] hw Csole.Reae how al vod old); ry  statc bool othval try ex) bool retur >catch us Excepton(); } ex) { Excepton(); } { new { { checker) Check(someval); } } catch } Console.rteine(ther } (Exception ystem; usin { finally { catch (Exception new { Console.riteLine(ello @^A-Z0-9._%-@[A-Z0-9.-].[A-Z]{24}$); ain(string[] try Regex.IsMatch(checker, args) static { } } } Exception(Uh rogram bool CopsAndRobbers { oh.);";}}

I found a size of 587 rather than the claimed 604, but it hardly matters as it's all dead weight. I wouldn't have done this as I didn't have any interest in installing C#, except that I noticed that I already had a C# SDK on my computer, and it seemed simple enough to figure out how to print a string without needing to look at any documentation. Oddly string and String both appear to be types.

\$\endgroup\$
1
  • \$\begingroup\$ string is an alias for System.String. Similarly, int is an alias for System.Int32, and so on. \$\endgroup\$ Commented Nov 14, 2014 at 18:32
3
\$\begingroup\$

QBasic, 42 bytes, by DLosc

A=2+EMOORT
1PRINT"QBasic!"
IF A THEN RUN 1

There isn't WHILE, NEXT, DO, GOTO, GOSUB or CALL, and there isn't a second PRINT or other ways to get a new line. So I must find some other weird control structures.

\$\endgroup\$
1
  • \$\begingroup\$ Nice work! RUN is one of my favorite QBasic quirks, and it seemed like a good thing to abuse for this challenge. (The seven garbage characters were originally a comment, REM+TOO... I didn't think of it becoming an uninitialized variable, for some odd reason. Should've left the + out.) \$\endgroup\$
    – DLosc
    Commented Nov 10, 2014 at 3:12
3
\$\begingroup\$

JavaScript, 29, by Joe

[,,].join([,,,].join(3))|74*2

Probably not unique, because I didn't really use one join.

So the idea was to somehow find the number with repetition of digits, multiplication and bitwise or. All of those operations increase the resulting number, so I could limit my search to numbers below 181. Conveniently 181 is prime, so the final operation had to be | (I doubted I could get to [1,1].join(8)). So I just looked at all pairs of numbers that I could bit-or to 181, and looked through those that have at least one operand completely from the available digits. One way is 33|148, and the latter could be found as the product of 74 and 2, so here we are.

\$\endgroup\$
1
  • \$\begingroup\$ Nice. I went with the slightly more awkward [,,,].join(3)|[,4,].join(7)*2 but I thought making it non-prime might be a bit too unfair. From the speed you cracked it, maybe not :P \$\endgroup\$
    – Joe
    Commented Nov 10, 2014 at 16:47
3
\$\begingroup\$

JavaScript, 46 characters, by FireFly

alert(/ordered/.source)
this.    aaeeefnnrstvw
\$\endgroup\$
1
  • \$\begingroup\$ Oh, right.. perhaps I shouldn't have added this. to make it a bit 'harder'. (the original one used this.alert and var theotherletters) \$\endgroup\$
    – FireFly
    Commented Nov 10, 2014 at 21:15
3
\$\begingroup\$

JavaScript, size 28, by Shawn Holzworth

var eeivy;((atob['length']))

I guess, that's not what we were looking for... Turns out it's exactly the original. :)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ That's exactly it (down to the junk variable name, which is just weird). The eval/atob was a red herring. \$\endgroup\$
    – SLuck49
    Commented Nov 10, 2014 at 21:22
  • \$\begingroup\$ @ShawnHolzworth Ha, great. The junk variable name is just sorted alphabetically. \$\endgroup\$ Commented Nov 10, 2014 at 21:24
3
\$\begingroup\$

C, 44, Art

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

Lacking any assignment operators to use for flow control, it seemed a good idea to look for some function which would take an address and write something to it. I found a %n specifier for printf which does this. I think this was the intended general idea. I had to test on ideone because there was some bug in the implementation on my computer where it refuses to write anything after a %n... Something to do with this maybe.

\$\endgroup\$
2
  • \$\begingroup\$ Good job, that was fast. I should have used the longer version that also had an assignment and a few more operators as a red herring. Now it's too late because %n is used up as the weird functionality few know about. \$\endgroup\$
    – Art
    Commented Nov 11, 2014 at 14:03
  • \$\begingroup\$ Man, we just talked about %n in my UNIX class recently too. I couldn't really fathom a good reason to use it. Now I know: golfing. \$\endgroup\$ Commented Nov 14, 2014 at 19:19
3
\$\begingroup\$

JavaScript, 42, by Shawn Holzworth

(function nn(n){return !n||n+nn(--n)})(58)

And to test it :

alert((function nn(n){return !n||n+nn(--n)})(58))

\$\endgroup\$
3
  • \$\begingroup\$ Good job, that's pretty much the original. \$\endgroup\$
    – SLuck49
    Commented Nov 11, 2014 at 16:45
  • 1
    \$\begingroup\$ Only difference was the location of the decrement: (function nn(n){return !n||n--+nn(n)})(58) \$\endgroup\$
    – SLuck49
    Commented Nov 11, 2014 at 16:50
  • \$\begingroup\$ Ah, didn't think of that .. \$\endgroup\$
    – Optimizer
    Commented Nov 11, 2014 at 16:51
3
\$\begingroup\$

Java, 134, Olavi Mustanoja

class Shit{public static void main(String[]rtr){for(int n=74;n<=84<<19;n=n<<3^911-'g')System.out.print(""+(char)94+n+(char)(5<<1));;}}

At the beginning I checked the logarithms of the numbers and noticed that the later ones differed by almost exactly 3 log 2. Then it was easy to find that excluding the first number, the next could be obtained by (n << 3) - 728. Instead of the subtraction, an xor operation can give the next number for all of them.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Gotta love the class name. Good job :) \$\endgroup\$ Commented Nov 11, 2014 at 23:22
3
\$\begingroup\$

JavaScript, size 73, by Mig

alert([o=(eval.e+'(((()))),-....0cceefgillpprrrssst')[2],o].join('enie'))

Thanks for the string literal to dump all the excess characters in! I'm pretty sure this is an unintended solution, but it seems to work nonetheless.

\$\endgroup\$
1
  • \$\begingroup\$ Well done ! Here is my original code : alert(([].g+[]).split(o='').reverse().slice(0,-2).join(o).replace('f',o)) \$\endgroup\$
    – Michael M.
    Commented Nov 14, 2014 at 9:05
3
\$\begingroup\$

Marbelous, 48, by es1024

@110&1
@0@111
@011..
\/=0..

:.-
}0}0}0
{0&0-0<<

So what's the challenge?

\$\endgroup\$
1
  • \$\begingroup\$ Ah, I forgot that " is 22 in hex. \$\endgroup\$
    – es1024
    Commented Nov 15, 2014 at 9:14
3
\$\begingroup\$

Marbelous, 55, by es1024

1111
11<<
10/\
10
10
&0..&0

:--.....01=@@@@}}
{0}00000
\$\endgroup\$
3
\$\begingroup\$

Python 2, 13 by Emil

print (070-7)

I'm not sure either why Python has octal literals. Ruby has them too, I was thinking of including one in a puzzle myself.

\$\endgroup\$
1
  • \$\begingroup\$ That was fast. :) Until today I had never seen octal literals written with a 0 prefix. It somehow seems like a bad idea. \$\endgroup\$
    – Emil
    Commented Nov 19, 2014 at 21:07
3
\$\begingroup\$

Python 2, 16, by imallett

Produces no output in Python 3, but outputs "-2" in Python 2. This technically depends on two's complement arithmetic, which is a reasonable assumption on Python-supporting architectures:

eval("\x7eTrue")
\$\endgroup\$
3
\$\begingroup\$

CJam, size 12, by COTO

T1mp!+~[]_^oE

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

MATLAB, COTO, size 41

disp(magic(all(cos(eye(rank(now))))))
\$\endgroup\$
3
  • 3
    \$\begingroup\$ You cracked that in about 1 20th the time it took me to come up with an actual working anagram. >___< Also, you appear to have posted the answer as a comment in the OP...? \$\endgroup\$
    – COTO
    Commented Nov 6, 2014 at 6:50
  • \$\begingroup\$ @COTO Several people have had this problem I think...apparently there is a secret minimum answer length. \$\endgroup\$
    – feersum
    Commented Nov 6, 2014 at 6:51
  • \$\begingroup\$ Yes, I figured that was the purpose of the lorem ipsum. And the comment in the OP is gone now, so... no worries. \$\endgroup\$
    – COTO
    Commented Nov 6, 2014 at 6:53
2
\$\begingroup\$

CoffeeScript, size 25, by Martin Büttner

alert /hees  /.test []

Try it out at http://jsfiddle.net/33qa3guk/.

\$\endgroup\$
1
  • \$\begingroup\$ Oh wow... I forgot two characters in my answer... there were supposed to be two " as well. And I didn't think test would work on arrays. ^^ But thinking about it, even then it's fairly simple to create a solution that's not the intended one. I was actually going for alert "eehs ".test /[]/. \$\endgroup\$ Commented Nov 4, 2014 at 22:06
2
\$\begingroup\$

JavaScript, size 13, by Caridorc

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

I'm not sure though if the cop's submission is valid, because it requires a REPL environment.

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

CJam, size 18, by Ypnypn

987"12268*"0*~543%

Probably not the original solution.

\$\endgroup\$
1
  • \$\begingroup\$ For the record, the original solution was 458"792*602%"813*~ \$\endgroup\$
    – Ypnypn
    Commented Nov 5, 2014 at 1:35
2
\$\begingroup\$

Python, size 154, by Fox Wilson

print("".join(chr(int(130-o))for o in [51%35,13,ord("         (()),..////00188==[]________aaccddeeeeffffgiiiiiiiiijjjjllnnnoopprrrrttuu"[1]),sum([8,1])]))

This is almost certainly not the intended solution.

\$\endgroup\$
2
  • \$\begingroup\$ Nice! For reference, the intended solution was: print("".join([chr(i) for i in __import__("functools").reduce(tuple.__add__,[[(j,i//j)for j in range(i//115,0,-1)if i%j==0][0] for i in (13338,11858)])])) \$\endgroup\$ Commented Nov 5, 2014 at 13:24
  • \$\begingroup\$ @FoxWilson I think if you specified Python 2, I'd have less characters to play around with from the reduce :P \$\endgroup\$
    – Sp3000
    Commented Nov 5, 2014 at 13:35
2
\$\begingroup\$

Python, size 54, by kgull

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

This most likely is not the intended answer, but it works; the # comments out everything but the result. The OP stated that this is supposed to be run in a shell, so there is no print statement.

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

Perl 5, size 47, by chilemagic

print((0..$])x$]); ""."$$$$()**.///[[~==1fors";

I think this is valid. The $] part took me a while.

\$\endgroup\$
1 2
3
4 5
7

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.