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
    Nov 6, 2014 at 14:34
  • \$\begingroup\$ @WumpusQ.Wumbley We've all been there... ;) \$\endgroup\$ Nov 6, 2014 at 14:35
  • 3
    \$\begingroup\$ I refuse to waste my time attempting to appease it. \$\endgroup\$
    – user15244
    Nov 6, 2014 at 14:35
  • \$\begingroup\$ Given the two question bodies, it appears that the scrambled/unscrambled answers are reversed \$\endgroup\$ Nov 6, 2014 at 23:31
  • \$\begingroup\$ Ruby, 23 by MegaTom = p %++.methods[80][1..-1] \$\endgroup\$
    – histocrat
    Nov 11, 2014 at 22:31

182 Answers 182

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

Python, size 48, by kgull

print('h'+hex(ord('\r')*pow(ord('#')//2,2))[2:])
\$\endgroup\$
2
\$\begingroup\$

PHP, size 22, by kenorb

echo(1.*0+(int)(7.1));

Or something like that... it's not really unique.

\$\endgroup\$
1
  • \$\begingroup\$ Great job, it was echo(int)((.1+.7)*10); \$\endgroup\$
    – kenorb
    Nov 5, 2014 at 14:14
2
\$\begingroup\$

Python 2, size 38, by FryAmTheEggMan

print(`[].__iter__`[::2].split()[-~1])

Taking letters from object at.

\$\endgroup\$
6
  • \$\begingroup\$ Congrats! also, Curses! ;p I also just noticed that 2 == -~1 which was probably not the best idea :S \$\endgroup\$ Nov 5, 2014 at 15:10
  • \$\begingroup\$ @FryAmTheEggman Ahaha was this not the intended solution or something? \$\endgroup\$
    – Sp3000
    Nov 5, 2014 at 15:17
  • \$\begingroup\$ No this is exactly what I had, it just didn't matter where you put 2 or -~1. I probably should have also done something like [30].__iter__ to make it more confusing... \$\endgroup\$ Nov 5, 2014 at 15:20
  • \$\begingroup\$ @FryAmTheEggman Ahaha that wouldn't really change much though, seeing as the repr is still the same \$\endgroup\$
    – Sp3000
    Nov 5, 2014 at 15:21
  • \$\begingroup\$ Yes, the point of that change would be to make guessing how I chopped the string more difficult, but I guess it probably wouldn't have changed much. By the way, did the `` give it away? \$\endgroup\$ Nov 5, 2014 at 15:27
2
\$\begingroup\$

C - 43, by Allbeert

This solution really ,sux, but it does actually work if you ignore the grumbling from gcc:

main(){printf(&__DATE__[10],1+1+1+',sux');}

(It will stop working in a few weeks, however...)

\$\endgroup\$
1
  • \$\begingroup\$ Nicely done! I realized printf worked as well as puts (intended solution) after I had posted the code. I also didn't know you could use single quotes for more than one character without an error! Learned something today :) \$\endgroup\$
    – Allbeert
    Nov 5, 2014 at 16:55
2
\$\begingroup\$

PHP, size 23, by bwoebi

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

I'm confused by why echo@$$c=b,$$c.$$cc.=b; doesn't work, while calling echo@$$c=b,${""}.$$cc.=b; directly does.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Interesting, I had echo$$c=$c.$c=@b,$$c.b; \$\endgroup\$ Nov 5, 2014 at 17:53
  • 1
    \$\begingroup\$ My original was echo$$c=$c.$c=@b,$c.$b; ... tiny difference to that one from @MartinBüttner \$\endgroup\$
    – bwoebi
    Nov 5, 2014 at 17:58
  • 1
    \$\begingroup\$ I can tell you why echo@$$c=b,$$c.$$cc.=b; doesn't work. in case of an expression (variable variables are considered as an expression), operands are evaluated in order. If there are simple variables, they're evaluated only when the operation between the two operands is done. $a.$a=1: $a is here only fetched when the concat operation has to be done, means after $a=1 was executed. But for $$a.$$a=1: $$a is an expression (as opposed to $a being a simple variable) is then evaluated just in order and only then $$a=1 is evaluated, ending up with effective NULL.1 == 1. \$\endgroup\$
    – bwoebi
    Nov 5, 2014 at 18:10
  • \$\begingroup\$ And also, ${""} can be reduced at run-time to a variable, so it's not considered like an expression. That's all. \$\endgroup\$
    – bwoebi
    Nov 5, 2014 at 18:14
2
\$\begingroup\$

Ruby - 58, by Rodolvertice

There are probably lots of solutions to this one.

puts 0x7d556657^0x3ffd88f9^0x1221442e^0xdd48ad1^0x08c58a00
\$\endgroup\$
4
  • \$\begingroup\$ Brute force? Original: puts 0xfd469501^0xd62f105d^0x4881d05^0xf7537e82^0x8d2a4c8a \$\endgroup\$
    – vero
    Nov 6, 2014 at 0:19
  • \$\begingroup\$ @Rodolvertice No, just figured it out in a text editor \$\endgroup\$
    – r3mainer
    Nov 6, 2014 at 0:29
  • \$\begingroup\$ Wow. You just did trial and error until it worked? I would never have that patience haha... +1 \$\endgroup\$
    – vero
    Nov 6, 2014 at 0:34
  • 2
    \$\begingroup\$ @Rodolvertice It wasn't trial and error \$\endgroup\$
    – r3mainer
    Nov 6, 2014 at 0:45
2
\$\begingroup\$

Perl, size 39, by GentlePurpleRain

$_=(~0);s/(\d\d)/ge_$2/;print$_=chr$1*4

With help from chilemagic.

\$\endgroup\$
3
  • \$\begingroup\$ That's valid, but the original was $_=20;$_=~s/(\d\d)/chr($1*4)/ge;print$_ \$\endgroup\$ Nov 6, 2014 at 15:14
  • \$\begingroup\$ @GentlePurpleRain your original outputs P when I run it, in your answer you said it outputs H. \$\endgroup\$
    – hmatt1
    Nov 6, 2014 at 15:54
  • \$\begingroup\$ It appears you are correct. It originally started with $_=18, and I changed it at the last minute, but apparently didn't update the output. I'm glad you were able to find a solution nonetheless. \$\endgroup\$ Nov 6, 2014 at 22:53
2
\$\begingroup\$

JavaScript, length 32, by hsl

Interesting use of the map() function there:

[atob('cHVHaVht')].map(alert)//+
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Or couldn't you just comment the map stuff out and alert the string directly? \$\endgroup\$
    – feersum
    Nov 6, 2014 at 9:43
  • \$\begingroup\$ @feersum Hah, that never occurred to me :-P \$\endgroup\$
    – r3mainer
    Nov 6, 2014 at 9:56
  • \$\begingroup\$ Nice one! In my quest to have it start with valid code, I never thought of using alert directly. +1 for getting the more complex answer. \$\endgroup\$ Nov 6, 2014 at 12:49
2
\$\begingroup\$

JavaScript, size 47, by palerdot

alert("a surprise!")//if("est")(it will tell  )

This was super easy though. There can be so many solutions to this too.

\$\endgroup\$
3
  • \$\begingroup\$ This is not my original code, though a lot of variations exist for this particular snippet. My original snippet does not contain any comments. \$\endgroup\$
    – palerdot
    Nov 6, 2014 at 11:14
  • 1
    \$\begingroup\$ Heh, I find the runnable code snippet quite amusing; it's not exactly very difficult to predict what it will do. :P \$\endgroup\$
    – Doorknob
    Nov 7, 2014 at 1:16
  • \$\begingroup\$ @Doorknob In a simple case like this, yes. Not when the whole compiler is present there. \$\endgroup\$
    – Optimizer
    Nov 7, 2014 at 7:15
2
\$\begingroup\$

PHP, size 44, by kenorb

$_=get_class_methods(@new phar);die($_[70]);

IMO, that one was pretty obvious (took me 10 minutes after first look).

I did a quick google search and observed that there were a lot of class having valid() as method... An coincidentally get_Class_methods() was in the string. After extracting that one, no issues anymore.

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

CJam, size 19, by Martin Büttner

"hunt !tacos" 'hiCt

This one seemed easy...

\$\endgroup\$
1
  • 3
    \$\begingroup\$ That was quick. \$\endgroup\$ Nov 6, 2014 at 15:46
2
\$\begingroup\$

PHP, 21, by kenorb

This one is easy if you know that one of the new features in PHP 5.6 (the version of PHP the code was tested in) is a ** operator for exponentiation:

<?=27**5;///***134689

Or alternatively:

<?=3**15;///***246789
\$\endgroup\$
2
\$\begingroup\$

C, size 30, Ethiraric

main(){printf("%d",__LINE__);}
\$\endgroup\$
2
  • \$\begingroup\$ Wow, didn't expect it to be that fast :) It is __LINE__ though, not LINE. I used gcc to compile it, don't know if it is different on other compilers \$\endgroup\$
    – Ethiraric
    Nov 6, 2014 at 15:26
  • 1
    \$\begingroup\$ @Ethiraric it is __LINE__ of course, but the site mangled it. \$\endgroup\$
    – feersum
    Nov 6, 2014 at 15:59
2
\$\begingroup\$

C, size 39, imallett

_;main(){putchar(_^'_');_++<9&&main();}
\$\endgroup\$
3
  • \$\begingroup\$ Almost character for character identical to the original (my ^ arguments are swapped). +1, as this was sortof nasty. I'm curious about how > would have helped? \$\endgroup\$
    – geometrian
    Nov 7, 2014 at 6:39
  • \$\begingroup\$ @imallett Actually it wouldn't have--I really was thinking <=. My first idea was something with just one statement like ;_;main(){_<=9&&main(putchar(_++^'_'));} although I guess that seems more convoluted than the actual solution. \$\endgroup\$
    – feersum
    Nov 7, 2014 at 6:47
  • \$\begingroup\$ @feersome: [N.B. GraphicsResearch|->imallett] I actually tried for a while to get a single statement inside the putchar, but couldn't figure out a nice way (precedence kindof kills it). \$\endgroup\$
    – geometrian
    Nov 7, 2014 at 6:52
2
\$\begingroup\$

Little Man Computer, size 63, The Wolf

503902000051000000000001111122223334455555666777888999999999999

If I'm understanding this correctly, all I have to do is put the number in the out box and then halt? OK...

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

Haskell, size 42, by proud haskeller

{data S=S{}deriving Show;main=print S;S=S}

Some clever things were done here: the empty record in the definition of S to reduce the number of spaces (this confused me a long time!), and it looked awful hard to use that extra equals sign from the extraneous S=S equation.

\$\endgroup\$
2
  • \$\begingroup\$ I didn't know you could group top level definitions together. I intended it to be an empty record pattern S{}=S. Should have had two more parentheses. \$\endgroup\$ Nov 7, 2014 at 11:00
  • \$\begingroup\$ I actually just thought the record definition would be harder to guess. \$\endgroup\$ Nov 7, 2014 at 11:37
2
\$\begingroup\$

Lua, size 28, by ChipperNickel

a=math print(a.asin(1)*a.pi)

Wow, this was actually really simple, why did I not try this earlier? Also, I learned that you can separate statements with nothing but a space in Lua.

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

Mathematica, size 18, by Arcinde

D[2#&@d!!,d]/.d->0

That was quite interesting. :)

\$\endgroup\$
1
  • \$\begingroup\$ Dang, nice job. \$\endgroup\$
    – jcai
    Nov 7, 2014 at 12:13
2
\$\begingroup\$

Ruby, 49, by Doorknob

$><<"'"+'
""'


%''
%''
%"'<<<<<<<<>>>>>>>>>% ?;"

I think I found a tiny shortcut?

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

Python (2), size 41, muddyfish

print(sum(map(ord,repr(exit.__repr__)))) 

I observed the result 6831 from this code for both Pythons 2 and 3 on my local machine. However, I managed to reproduce the output 6314 with (http://ideone.com/700qVt). Ideone's Python 3 didn't even recognize the exit function.

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

C, size 53, by FireFly

s(x){return x?x*s(~-x):!x;}main(){printf("%x",s(9));}

Nice factorial program :)

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

Arithmetic, size 31, by Cris

(((((2*2+1)*2+1))*(1+(1+2)*2)))

This may not have been the intended solution because of the unused parentheses, or maybe they were red herring.

\$\endgroup\$
1
  • \$\begingroup\$ I think that this was the intended output: ((((2*2)+1)*2)+1)*(((1+2)*2)+1) But the functionality is the same. Great catch! \$\endgroup\$ Nov 8, 2014 at 6:48
2
\$\begingroup\$

Cris, ECMAScript, 66

eval(atob("J2slzzuuuspmlkihgccbbbaZZYYWSSKKKED995555222S2AnCjsx"))

...

Cris, ECMAScript, 70

eval(atob("DScg12224599ACDDMMNNNOQQTTYZZbcgjklmpssuuuwwyzzzOScKMSY1"))

......

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

Python 2, muddyfish, 37

print(memoryview(str(Ellipsis)).ndim)

I'm glad I made that Python builtins anagrammer.

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

Java, 108, durron597

class o{{ }public static void main(String...r){System.out.printf("%.6f",('a'*'+'/'\t'-'l')/('m'+'\n'-6.));}}

This was my second pi-printing program today. Given the low precision of this one, the second-most famous rational approximation, namely 355/113, was sufficient to produce the correct digits. It seemed like this fraction should be obtainable with some math on character literals. After some trial and error I finally found an expression ('a'*'+'/'\t'-'l')/('m'+'\n'-6.) which used all the characters it needed to. One convenient thing was that I had the choice between printf or format which both behave identically here.

\$\endgroup\$
1
  • \$\begingroup\$ Nicely done. It's quite different from my original though (which is also just math on character literals), which has no wasted {}, for example. If you want to try to figure out mine, my hint is that it's class pi{public static void main(String...lnr){. Perhaps the answer set would be smaller with class z and String...z \$\endgroup\$
    – durron597
    Nov 8, 2014 at 19:34
2
\$\begingroup\$

QBasic, 37 bytes, by DLosc

PRINT 1E7 AND 11053811

R=LEN("*?RY")

I immediately noticed that all the letters of AND were present in the code. (In QBasic, the Boolean operators are bitwise, and true is -1.) Then I wrote a script to find possible combinations of operands by brute force, ignoring zeros to allow for E notation. Once I found a usable combination in the list, all that was left was to deal with the remaining characters.

A single space is printed before the number (where the minus sign would go for a negative number). The scrambled code also prints a space before the number it prints, and that is not described as part of its output, so I assume that that detail is insignificant or was mistakenly omitted.

\$\endgroup\$
1
  • \$\begingroup\$ My original actually multiplied two numbers before ANDing the result with 1E7 (thus the *), but I guess with bitwise operators there's always going to be lots of possibilities. Nice work! \$\endgroup\$
    – DLosc
    Nov 11, 2014 at 2:07
2
\$\begingroup\$

Python, size 55, by FireFly

____acdfiimmnooprrt={2:.9,}
print(801**sum(range(5))+1)

The funny thing is, my initial solution only worked on Python 3 and it was only until FireFly pointed out that I should inline my 801**sum(range(5)) instead of assigning it to a variable that I got this working for both Python versions.

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

Java, Size 97, Olavi Mustanoja

class _{public static void main(String[]s){for(int b:"534g".getBytes())System.out.write(b^'m');}}

There are not too many possibilities with only 1 character ^ usable as operator and lack of p (for printing operation).

I wither the input down to 345_gsm and do some math to map it to the output.

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

Ruby, 23 by MegaTom

p %++.methods[80][1..-1]

Edit: So that's where the answer went. Converting back to an answer, hopefully. Thanks for specifying an interpreter, methods[80] is definitely version- and implementation- dependent. Using + for the percent-string delimiter is a nice touch.

I think I found this easier than I would've just because I'd been thinking of doing some similar tricks.

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

Ruby, size 17, by Stephen Touset

$><<$-W?$?:$:>-pi

Test it on ideone.

Most certainly not the original code. $-W is the value of the command-line argument -W (warning level) which defaults to 1. The rest is just to get rid of the other characters, so I'm putting some undefined variables and operators in the else branch of a ternary.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ My original was $-p??:>$i:$><<$-W. I wanted to use the $><< trick, and the (very not well-known) flag-based globals like $-W. Unfortunately, that's short enough (7 characters) to be easily brute-forceable. I rationalized that it might be tricky to include the letter p as a red herring, and the rest was there to reduce the effectiveness of brute force. \$\endgroup\$ Nov 13, 2014 at 19:32
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.