Unscramble the Source Code [robber thread for cracking attempts]

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.

Too many solves

20 solves

15 solves

10 solves

7 solves

5 solves

4 solves

3 solves

2 solves

1 solve

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

C, 43 bytes, FryAmTheEggman

Extremely abusive C code; works in the provided tester. Assumes no command-line arguments are passed (which is the default).

main(ui,abdenprsx){printf(&"%se7en%"[ui]);}


Note that the final % doesn't get printed out (at least in the tester provided by the poster and with my local copy of GCC 4.8; Clang refused to compile this code).

• Nice. I only didn't do that because I thought it would print the % at the end. – feersum Nov 7 '14 at 22:04
• @feersum: yeah, I was a bit surprised that it didn't print. (I'm guessing that it's actually UB, but there's plenty of UB in the program already). – nneonneo Nov 7 '14 at 22:06
• Ah I thought there would be a way around it. Nice work, though :) I'll add the original to the question... – FryAmTheEggman Nov 8 '14 at 3:36
• I'd like to hear if my version worked in your environment by the way. I think it mostly avoids UB. – FryAmTheEggman Nov 8 '14 at 3:42
• @FryAmTheEggman: Fails. My environment (OS X) doesn't define unix. (Your original harkens back to an old IOCCC contest entry). – nneonneo Nov 8 '14 at 3:53

Python, size 41, by Sp3000

xx=x=6;exec("x*=6*6;xx*=x;"*xx);print(xx)


I racked my brains for half an hour trying to get to 6**49 by some combination of x*=6, x**=6, and x*=x, but there were never enough *s. Then I remembered something about squares being the sum of consecutive odd numbers... From there it was easy. ;^)

• Nice! I was actually going for the exec loop x=xx=6;exec("x;xx*=6;x*=x"*6);print(x*xx) but I screwed up :P – Sp3000 Nov 8 '14 at 7:49
• @Sp3000 I'm glad, because I probably wouldn't have gotten that version! :P That's clever with the semicolon placement--you've just taught me a new Python trick. – DLosc Nov 8 '14 at 8:09

CJam, size 34, by Dennis

"!,wcoo tkea"Jb" n heyre srwe"Bbma


Other solutions:

"newk,r !ywsre"Bb" e cto aeho"Jbma
"erwy !tro"Jb" knsecew,ho"Bbma  ea
"rese ohro  cn"Bb"!ew,a yektw"Jbma
"sr  k!oore,"Bb"nyeewtwch"Jbma  ea
"nwetkhs yr "Bb"o!eerc w,"Jbma eao
"!,wcoo tkea"Jb" n heyre srwe"Bbma


This is mainly based on Martin Büttner's idea. First assume the solution is either "..."Jb"..."Bbma or "..."Bb"..."Jbma. Then find some small fractions p/q whose tangent value is rounded to that number. Try every k and search for a pair of string which can be decoded into kp and kq. The search program is proven fast in cracking of the previous answer.

At first we have overestimated the probability and started with only two pairs of p and q. Nothing is found. But finally I changed the program to enumerate all possible ps and qs, and it worked.

There should be other ways to generate the two numbers other than kp, kq. But I don't know where to start the search in that case.

C++, size 192, Arcinde

#include<stdio.h>
#define d double
d i7(int y){return y- -1;}d g(d x,int i){return x?x/i- -g(x*i/4/i7(i),i7(i7(i))):x>x;}int (main)(d***dfffgy){printf("%.15f%",7?g(3,1):0,0.,-0.,0,1,2,2,2,4);}


I used the series for pi from here for which "history books credit Sir Isaac Newton." After making a short program based on that, the main difficulty I had with using the provided characters was that while I used three additions, I had no + available, and was one - short of using all double-minuses. I resolved this by creating a function i7 which subtracts -1 from a number. An unfortunate thing that happened is that I used all the / for division, meaning I had a large volume of unused characters to stick in various spots instead of simply commenting them out.

• I'm impressed. Props for writing a much shorter pi program than me ;) I used 4(arctan(1/7)+2arctan(1/3)), plus I wrote another function to compute powers. – jcai Nov 8 '14 at 15:48

JavaScript, size 82, by Ismael Miguel

var v='',i=0;for(;i<(21<<2)-~1;)v+=i^++i;console.log(v+i)//,.13<<=[[[[]]]]iiijnozz


Previous version:

var v='',i=0;for(;i<(21<<2)-~1;)v+=i^++i;console.log(v+i);//,.13<<=[[[[]]]]iiijnzz

• NICE!!!!! This is the code I had: for(var i=0,v=[],z=[2<<2]+[3<<1];i<z;i++)v[i]=i^~i/-1/1;console.log(v.join('')+i);. I guess that my mistake was that 21<<2 == [2<<2]+[3<<1]. But nice one!!! – Ismael Miguel Nov 8 '14 at 16:31
• Your original code has one extra o and one less ;. What happened to that? – jimmy23013 Nov 8 '14 at 16:49
• Weird................. Thanks for the pointer. I did it by hand, which it resulted in human error. You should update the answer to reflect your catch. – Ismael Miguel Nov 8 '14 at 18:32

Marbelous, size 36, es1024

9C
Dr=0
^3
+O
+O!!

:Dr
}0
++
/\{>{0


There is no trailing line break, so that we remain at 9.

After another very fruitful discussion session with Sp3000, at last, one of the Marbelous submissions is cracked! :)

I can't really explain Marbelous in the scope of this answer, so if you have no idea what I'm talking about, have a look at this reference.

Let's look at the output first: it's 100 ones and zeros, 8 of them at a time (with some offset in the cycle). This suggests that we have some loop that increments a marble 100 times, and printed 0 or 1 depending on the 4th byte. Both of those are pretty convenient because, starting at 9C (in hex) is 156. Incrementing 100 times overflows, so we can abort the loop with a =0. Furthermore, we have access to the fourth bit with ^3. And if we increment before outputting, then we will also correctly start with 3 ones.

Setting this up was a bit trickier though. Especially, since we got really stuck on the idea of naming the board Or, so that we would have the Ds as hex digits (and we also thought there were two ++ devices). But we just couldn't find a way to add 48 to the 0 or 1 resulting from ^3 (which is necessary to turn them into 0 or 1 characters). But at some point I had an epiphany, and realised that O is 24 in base 36, so we could actually increment by 48 using +O twice.

The rest was fairly simple to deduct from the available characters and the requirement to have no empty cells in the boards. In particular, there is no way to move a marble upwards in this, so the only way to create a loop is horizontally. The clue here was the cylindrical board, which allows you to just constantly push things to the right, until =0 lets the marble fall. This also meant that the ++ device had to go inside the subboard, because you can't prevent it from letting the marble fall.

So in summary:

• 9C is a literal marble which starts its life at value 156.
• There is a subboard Dr which takes in a marble, increments it, and spits out the result both downwards and to the right.
• =0 lets the result fall if we hit 0, otherwise pushes it to the right, and back into Dr.
• ^3 takes the marble that falls out of Dr and returns 0 or 1 depending on the 4th bit.
• +O increments by 24 (twice).
• When the result falls off the bottom of the main board, the corresponding ASCII character is printed.
• !! terminates execution. This isn't necessary to break the loop (that wouldn't continue anyway), but it swallows the null byte, that would be printed if the 00 marble were allowed to fall off the board. It's important to put the !! in the last row, otherwise the final 0 character wouldn't have time to get printed.

Python 2, size 132, by Vi.

EDIT: Solved the original given that it didn't use exec at all. For some reason, even though I came up with using compile() to trigger the except in the from __future__ import instead of exec(), I didn't think to use compile+eval for the rest.

eval(compile('try: compile("from __future__ import braces","1","single")\nexcept SyntaxError as q:\n\tprint q[0][6:]',"2","single"))


I'm pretty sure the answer to the hint given "Don't count ones which exist. Count ones which do not exist" is "braces".

How it works: The easter egg import from __future__ import braces triggers a SyntaxError: not a chance. The idea was to catch this exception and extract the last word from it; but you can't use try:from __future__ import braces because from __future__ imports must occur at the top of the file (this is because they aren't really imports, they're directives to the interpreter at compile-time to enable features). This is why you can trigger the exception by compiling the import without executing it. Additionally, to compile the try/except in single-statement mode, you need the \n\t after the except. I'm not sure why this is necessary; it works without the \n\t if you use exec-mode. Additionally, the "1" and "2" aren't strictly necessary; those could be left empty.

EDIT: Cracked shorter variant.

exec('try:exec("from __future__ import braces")\nexcept SyntaxError as q:print q[0][6:]\t\n12')


I'm not sure what to do with the 12\\nt characters. They didn't seem to fit, but putting them at the end like that works fine.

This works on basically the same idea as the original, but leverages exec instead. The second exec isn't strictly necessary, though, since all you have to do is compile the import statement.

Personally, I think it would have been a little more interesting to use StandardError instead of SyntaxError, or perhaps an import sys; and sys.last_value[0][6:], but with the dot in there I imagine a whole lot of other solutions would crop up.

• That's about what I had too :/ pretty sure from __future__ import braces was the intended idea. – Sp3000 Nov 13 '14 at 2:31
• Yeah, me too. I tried a lot of other things, like except StandardError (two too many ds, and one too many rs) and I managed to get an extra x removed by switching to compile() instead of exec(). I also tried stuff like sys.last_value or sys.exc_info() but still nothing. – Alex Van Liew Nov 13 '14 at 5:10
• Congratulations: from __future__ import braces is the answer. – Vi. Nov 14 '14 at 2:05
• 12 is for [6:12]. I'm not too Pythonic yet... Original solutions are now mentioned in the question. – Vi. Nov 14 '14 at 2:13
• @Vi. Ah, indeed. [6:12] would do it. What I haven't gotten the hang of is extended slicing; you can do some really weird stuff like [::6] and I have no idea what it does but you can do it. I think you can do [-1:] to reverse a list, although reverse() is a lot clearer. – Alex Van Liew Nov 14 '14 at 7:14

JavaScript, size 69, by Shawn Holzworth

f=f=(f=0x76f2156a6c[r='toString'](30))+f+f+' '+((0x25a1335*7)[r](30))


That took a while. This should be similar to the original, though the constants are probably different.

• Good job, the original used the same constants. Also just noticed in the original I assign (0x25a1335*7) to f for no reason at all – SLuck49 Nov 14 '14 at 20:44

Python 2, 29 bytes, by Dennis

emnsssssyyy= str().strip;ord;


Please, good bot, do not convert me to a comment!

• For the record, I was going for import sys;sys.stderr=sys;n(). – Dennis Nov 5 '14 at 3:10

JavaScript, size 26, by hsl

alert(998|(103>8>0&41>-0))


And some random text to prevent it converted into a comment.

• Well, that's totally different from what I intended, but it works. – NinjaBearMonkey Nov 4 '14 at 23:17
• Here's the original solution that was much more complex: alert(-9>>>011&(480|0839)) – NinjaBearMonkey Nov 5 '14 at 2:51

C++, 56, by hosch250

int main(){for(int c=33;c<251-124;+4)c+=printf("%c",c);}


Note that in order to get this to compile with GCC as a C++ program, I had to tell GCC to include stdio.h:

$g++ -include stdio.h -o 40974 40974.cpp$ ./40974
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~  The program does compile without -include in GCC's C99 mode though: $ gcc -std=c99 -o 40974 40974.c
40974.c: In function ‘main’:
40974.c:1:1: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
int main(){for(int c=33;c<251-124;+4)c+=printf("%c",c);}
^
40974.c:1:41: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
int main(){for(int c=33;c<251-124;+4)c+=printf("%c",c);}
^

• Looks like I'm a little late. I found another version though : int main(){for(int c=33;c<144-22+5;c+=1)printf("%c",c);} which still needs stdio.h. – Ethiraric Nov 5 '14 at 8:56
• Approaches with -include should not be considered valid. It's just like claiming a file containing A can have any behaviour you want, by compiling with the appropriate -DA=... command-line option: your claimed "source" file does not include the complete source. – hvd Nov 5 '14 at 9:24
• @Ethiraric You found my solution, although both are valid. I did not need stdio.h, although I did have stdafx.h. I was told before that I did not need to count that because that is a VS thing. It probably includes stdio.h somewhere in it. – user10766 Nov 5 '14 at 16:23
• @hvd I am not compiling with a command-line. I am running this code from Visual Studio and entering no extra commands. Also, VS would not even accept -include anyway - I would need to use #include, so would that invalidate my answer too if it didn't work on your computer? – user10766 Nov 5 '14 at 16:25
• @hosch250 In my opinion, it's fine that you don't count the contents of the stdafx.h file as part of your source (since it's unmodified from what's provided by the implementation, even if it's copied to your project directory), but it's not fine that you don't count the #include "stdafx.h" line as part of your source if it's needed for your project to compile. FWIW, Visual Studio behaves like GCC in that it does accept your intended answer in C mode without any #include directives, as long as precompiled headers are disabled in the project options. – hvd Nov 5 '14 at 17:12

Python, size 56 by Fox Wilson

print("".join([chr((i+70)^32)for i in (2,3,-70,7,9,7)]))

• You have a few stray parentheses in there, but this is the intended solution. – Fox Wilson Nov 4 '14 at 23:51
• Oops! Fixed. – user1354557 Nov 5 '14 at 15:33

Python 3, size 37 by matsjoyce

print(*[_*_ for _ in range(2*2*2+2)])


Let's add some more text so that this one doesn't get auto-converted to a comment.

• I ran into the same problem, and as a result Optimizer almost beat me to it. ;) – Martin Ender Nov 4 '14 at 21:52
• Can you explain the problem where solutions get converted to comments? (I haven't seen this happen, but should I add some text to my solution as a precaution?) – user1354557 Nov 4 '14 at 23:48
• Err, that's not quite right, as my solution prints the numbers separated by spaces, not newlines. – matsjoyce Nov 5 '14 at 7:36
• Whoops, make that print(*[_*_ for _ in range(2*2*2+2)]) then. – xnor Nov 5 '14 at 7:48
• Yup, that's it. Do you want to put that into the answer? – matsjoyce Nov 5 '14 at 17:04

Pyth, size 35, by FryAmTheEggman

llo    oCGd"ProgrammingPuzzesandef"


Simply lg(len("Length 22 string")), extra characters disposed of at the front.

• Yeah, it didn't seem like anyone else was trying. I thought a solution like this might be doable, but the original was lemsPCdPG with the rest in a supressed print string. – FryAmTheEggman Nov 8 '14 at 15:01

JavaScript, 94, by Shawn Holzworth

v=['0',01,7,8,5,7,8,4,44,11,8,41,1,1+1];a=alert;r='';for(x in v)r+=(a+(1==0))[v[x]]||'h';a(r);


Works only in SpiderMonkey, it seems (i.e. Firefox). This took me forever, and if it was slightly more clever with the indices I think I'd've given up.

• Very nice. The original works in Chrome and Firefox... though 'fun in the hun' is hilarious. – SLuck49 Nov 10 '14 at 13:07

Python, size 34, by Sp3000

print(str([{.6,}])[-4])
_=...;__=_


The trickiest part was trying to get rid of the leftover characters. :P

• Yeah that was awkward. Within 3 minutes of me posting I realised that my red herring had backfired. :/ A solve is a solve though, so I'll put up the intended solution was well :) Good job – Sp3000 Nov 11 '14 at 3:26

C, size 48, by es1024

main(f){f='ma'-lgamma(0xfe.dp9),printf("%d",f);}


I'm very unsure about this one. It depends on implementation defined behavior (character constants with more than one character, see C99 6.4.4.4 point 10), but happens to produce the right result on Linux with gcc and MacOS with clang. Depending on ASCII I wouldn't even mention, but this is so unusual that it feels very dodgy.

• That's exactly the original! – es1024 Nov 12 '14 at 6:41

Ruby, size 35, by histocrat

(_=->h{:shadily.display})[_]||_===_


Interesting, I did not know you could invoke lambdas with ===... I mean... why?

• Nicely done. Original code was (_=->h{:shadily.display||_})[_]===_. I think the === invocation is because Ruby calls === in case statements under the hood, so you can use lambdas as your conditions. – histocrat Nov 12 '14 at 15:43
• @histocrat Ah that makes sense. I like your version, too :) – Martin Ender Nov 12 '14 at 15:46

CJam, size 19, by Ypnypn

923"4593*JJ#%"786*~


Test it here.

That was close... the seven days had already passed, by Ypnypn did not yet claim immunity by releasing the original source.

Explanation

923                 "Push 923 on the stack.";
"         "786*~ "Repeat that string 786 times and eval it. Just a loop, basically.";
4593*           "Multiply by 4593.";
JJ#        "J is a variable initialised to 19, so compute 19**19.";
%       "Modulo.";


Cracking

I was fairly certain that "_"_*~ was used to make a loop, and that % was used as modulo to keep the numbers small. (We've seen other ways to do that, but I don't think that would have worked here very well, because you couldn't put the result of your computation in a string.).

So first guess I ventured was that the divisor of the modulo could be 1919. Looking up how much that is, it turned out to be on the same order as the desired result (about 4 times the result), which suggested that this is actually a very likely choice. That left only *, so I figured the code would be of the form

 _"_*JJ#%"_*


Where the _ are filled from the numbers. That's *10!/2/2 * binomial(9,2) = 32,659,200* possible permutations. That seemed to be doable by brute force. :)

The only thing that would blow this up is having a large number before the *... with up to 8 digits, it could basically square the number of iterations needed. So I thought, let's limit that to at most 3 digits (which was apprently quite lucky, seeing that solution actually had three digits there). Then I just reimplemented this framework in Mathematica and wrapped it in a loop over all such permutations:

perms = Permutations@{2, 3, 3, 4, 5, 6, 7, 8, 9, 9};
big = 19^19;
Map[
(
If[#[[2]] != perm[[2]], Print@#];
perm = #;
For[i = 2, i <= 9, ++i,
a = FromDigits[perm[[1 ;; i - 1]]];
For[j = Max[i + 1, 8], j <= 10, ++j,
b = FromDigits[perm[[i ;; j - 1]]];
c = FromDigits[perm[[j ;; 10]]];
x = a;
For[k = 0, k < c, ++k,
x = Mod[x*b, big];
];
If[x == 500827930823087774653348, Print@{a, b, c}]
]
]
) &,
perms
];


After about two hours (shortly before completing the full search) this produced

{923,4593,786}


which I was able to verify in CJam. :)

Python 2, size 69, by muddyfish

import tabnanny as t;print(t.__name__[:3])or((({3:_efisssw[[]][:]})))


tabnanny is a standard Python module, but I am just borrowing its name here to get the "tab" string.

Interactive Python 2.6, 15, MrWonderful

43**(314)/(1+2)


I did some (imprecise) brute force for i and j where math.log(N * j, i) is very close to an integer.

• Nicely done. I was a bit disappointed in my first attempt, so I thought about how I'd attack my challenge this time. ;-) Thanks! – MrWonderful Nov 14 '14 at 19:35

Golfscript, size 20, by Josiah Winslow

print "hello world!"


Tested at http://golfscript.apphb.com/.

• Not exactly what I was going for. I was going for "hello world" print. But good solution! It's hard to come up with something for a challenge like this. – Josiah Winslow Nov 5 '14 at 1:47
• @JosiahWinslow "hello world!"rn ipt also works. – jimmy23013 Nov 5 '14 at 5:12

PHP, 14, by Tryth

aa:a?:a?:a::a;


Tested working in PHP 5.5:

$php -nr 'aa:a?:a?:a::a;' | wc -c 0  Java 6+, 101 bytes, by Rodolvertice class ou{public static void main(String[]h){for(int t='l'|'s';t>0;t/=2)System.err.append(t+"4"+t);;}}  Outputs to stderr. Demo on ideon I figure out the pattern of the output quite easily: 127 4 127 63 4 63 31 4 31 15 4 15 7 4 7 3 4 3 1 4 1  This suggests the tokens /=2, for(;;), t+"4"+t, >0. for is taken from short free;. The number 127, the 4 ' and | also suggests the use of | with 2 char. The tricky part is to pick out t from the rest of the code (out -> err, println -> append, class t, the remaining part of short free;). • Well done! Nice description too. +1 – rodolphito Nov 5 '14 at 15:11 • btw the extra semicolon was because in the original i had declared int t outside the for loop :P – rodolphito Nov 5 '14 at 15:14 Befunge-93, size 17, by user23013 I'm not sure what all that extra stuff on line 2 is doing there... "@",69+# >_-/*%pv  Try it out here • The original solution was ",96*-/@ "p#v>+_%. It was a mistake leaving a # there. Line 2 was for putting the other ". – jimmy23013 Nov 5 '14 at 11:39 JavaScript, size 61, by jsh x=function() {return 1;};alert((typeof (typeof x)).slice(-4)) BBC BASIC, 187, by Beta Decay This just prints out a long sequence of ASCII codes: PRINTCHR$(121)CHR$(111)CHR$(117)CHR$(39)CHR$(108)CHR$(108)CHR$(32)CHR$(110)CHR$(101)CHR$(118)CHR$(101)CHR$(114)CHR$(32)CHR$(99)CHR$(114)CHR$(97)CHR$(99)CHR$(107)CHR$(32)CHR$(109)CHR$(101)


PHP, Size 30, by Tryth

__halt_compiler();t101hant.net


Just stopping the parser and ignore everything else to have no output.

Pyth, size 71, by FryAmTheEggman

*tC"y"l"Han Solo: Never Tell Me The Odd
-3P0: Sir, the possibii,... s!"


There have to be a ridiculous number of possiblities here, but this seemed to be the easiest - get 120 from chr('y')-1, and 31 as the length of a string, and multiply. Newline is a super-comment.

• Yeah, that was the idea :) I believe I got it by doing 47*78+54, but I cant find my source right now... – FryAmTheEggman Nov 6 '14 at 3:52

CJam, size 32, by Dennis

"tb srcr wB!eyo awm ,kheeonae"Jb


Just guess the answer should be something like "..."Jb` and then brute-forced it.