45
\$\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\$ 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\$ 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\$ Commented Nov 11, 2014 at 22:31

183 Answers 183

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

PHP, 33 bytes, by Ismael Miguel

echo 0X1^BXcdeilnu08DFHTTTgk467; 

Tested on ideone.

This might actually also work on Windows. All it does is xor a hexadecimal 1 with an undefined constant which yields 0.

For the Windows one you can use

echo 7^'6cdeilnudBXX4'; 

which should also work on both platforms, because the string is simply coerced into an integer (being 6), and then we xor that with 7.

I'm curious what those were supposed to be.

\$\endgroup\$
5
  • \$\begingroup\$ Linux: PHP Parse error: syntax error, unexpected 'Xdeilnu0018DFHTTTgk' (T_STRING), expecting ',' or ';' in /home/gn2Uey/prog.php on line 2 but the windows is correct. But really nice try! \$\endgroup\$ Commented Nov 9, 2014 at 22:24
  • \$\begingroup\$ @IsmaelMiguel sorry, the link is wrong, but if you use the code in my answer it works. I've fixed the link now. \$\endgroup\$ Commented Nov 9, 2014 at 22:28
  • \$\begingroup\$ writecodeonline.com/php -> runs fine here. But yeah, you cracked it. My mistake was leaving the 1 in the code. The code I has is this: Linux: echo include H010D67XT^gTTFkXB48;. Windows: echo include '67X'^XB4; \$\endgroup\$ Commented Nov 9, 2014 at 22:31
  • \$\begingroup\$ @IsmaelMiguel Wow, I must have been blind, I did not see that the lowercase letters spell include. \$\endgroup\$ Commented Nov 9, 2014 at 22:37
  • \$\begingroup\$ And I didn't see I left that 1 behind. But it was really a nice catch! \$\endgroup\$ Commented Nov 9, 2014 at 22:43
1
\$\begingroup\$

QBasic, 79 bytes, by DLosc

print"Iodine" if f then scReen BLaaabbefgghhhiiiiiiiikkllnnossstt,u-u.u 
\$\endgroup\$
1
\$\begingroup\$

Bash, 47, Vi.

If you saw a $100 bill lying on the ground, wouldn't you pick it up?

Don't know much about bash, but I tested it and it works.

printf pp;o='${cel-sr(xe\ pp/pp/) fec1/; }' 
\$\endgroup\$
1
  • \$\begingroup\$ Now try to find the original solution. Maybe I'll manage to change the task, so easy way whould stop working. \$\endgroup\$ Commented Nov 12, 2014 at 14:51
1
\$\begingroup\$

DC, 28 bytes, by MichaelT

[ls+dn11ls1+dss<n]sn1ss0lnx 

But I counted 27 bytes. Maybe there is a newline...

\$\endgroup\$
3
  • \$\begingroup\$ Off by one error in my counting. But yep. You got it. My original version was: 1ss[lsd1+ss+dn11ls<n]sn0lnx \$\endgroup\$ Commented Nov 13, 2014 at 23:20
  • \$\begingroup\$ One debate I had with myself when doing this was if I should reuse the same letter as operators for the registers, or if I should have used different registers (instead of s and n for registers, maybe c and q or the like) - any insight into the relative difficulty there? \$\endgroup\$ Commented Nov 13, 2014 at 23:44
  • \$\begingroup\$ @MichaelT It's obvious there are some registers in this program. I don't think it would be harder or easier just by changing their names. Those extra ss and ns are otherwise useless. It might be harder, if you made 1 a register and the number 1 is generated in other ways. \$\endgroup\$ Commented Nov 14, 2014 at 0:51
1
\$\begingroup\$

CJam, 51, by Optimizer

"JamesBdo,"YZ+/)BA*c+Y*Y%:BS@SB)))[JW:Z____)ci+*]U* 
\$\endgroup\$
1
  • \$\begingroup\$ Nice, this was the original : YY+_B*J)_*@/_A+_)BZZ+*d]W%:c:BoY,U*S["James"SB)i))c \$\endgroup\$ Commented Nov 13, 2014 at 19:06
1
\$\begingroup\$

Brainfuck, 39, by Mig

+++++++[->++++++<]>[->++<]>-.----.++++. 
\$\endgroup\$
3
  • \$\begingroup\$ Nice ! Original : +++++[>++++[>++++<-]<-]>>+++.----.++++. \$\endgroup\$ Commented Nov 14, 2014 at 10:19
  • \$\begingroup\$ Huh, and I thought I had matched your program perfectly. Neat how the characters used ended up exactly the same, then. \$\endgroup\$ Commented Nov 14, 2014 at 11:49
  • \$\begingroup\$ Yeah I was pretty surprised too. \$\endgroup\$ Commented Nov 14, 2014 at 12:48
1
\$\begingroup\$

Python shell, size 15, xnor

1215954^1548696 

Obtained by brute force in 1.42 seconds.

Code used to find solution:

#include <iostream> #include <algorithm> int main(){ int digits[] = {1,1,1,2,4,4,5,5,5,6,6,8,9,9}; int ndigits = sizeof(digits)/sizeof(digits[0]); do{ int n1 = 0, n2 = 0; for(int i = 0; i < ndigits - 1; ++i){ n1 = (n1 * 10) + digits[i]; n2 = 0; for(int j = i+1; j < ndigits; ++j) n2 = (n2 * 10) + digits[j]; if((n1 ^ n2) == 339018){ std::cout << n1 << ' ' << n2 << std::endl; return 0; } } }while(std::next_permutation(&digits[0], &digits[ndigits])); } 
\$\endgroup\$
3
  • \$\begingroup\$ Different from my original, but that's not surprising. How did you brute force it? Did you just count up? \$\endgroup\$ Commented Nov 15, 2014 at 7:05
  • \$\begingroup\$ @xnor I added the code I used to the answer \$\endgroup\$ Commented Nov 15, 2014 at 7:05
  • \$\begingroup\$ I made a new bigger version. Happy cracking. \$\endgroup\$ Commented Nov 15, 2014 at 10:27
1
\$\begingroup\$

Python shell, size 21, xnor

6446781078^9350512293 

Obtained by brute force in ~27 minutes.

Code used:

#include <iostream> #include <cinttypes> #include <cmath> inline bool check(int64_t a, int64_t b){ int used[10] = {}; do{ auto r = std::div(a,10ll); ++used[r.rem]; a = r.quot; }while(a); do{ auto r = std::div(b,10ll); ++used[r.rem]; b = r.quot; }while(b); if(used[0] > 2) return false; for(int i = 1; i < 10; ++i) if(used[i] != 2) return false; return true; } int main(int argc, char **argv){ int64_t i = 1ll << 32; while(!check(i,i ^ 15788895283ll)) ++i; std::cout << i << ' ' << (i^15788895283ll) << std::endl; } 

This checks every integer starting from 2^32 until it and its matching integer use up all the characters provided.

\$\endgroup\$
1
\$\begingroup\$

C++, 244 bytes?, by Gabe Evans

#include<iostream> int main(){int(CCDD)='%';char(a)[14]={'h','e','l','l','o',22+20/2,'w','o','r','l','d','!'};CCDD+=CCDD<=a[0];{{}};aa:adffillllllnnnnnnnnnnnnooooooooooooorrrrrrrrrssstttttttttttttttuuuuuuuuuuuuwwwwww:cout<<a;} 

It was a bit of a struggle getting all those spare characters out of the way. You can see the code working here.

\$\endgroup\$
1
\$\begingroup\$

Insomnia, 14, by n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

e9-i|yig9s pre 

\$\endgroup\$
1
\$\begingroup\$

C, size 62, by Olavi Mustanoja

#include<stdio.h> #define _ +8 int*main(){printf("%d",1 _ _);} 
\$\endgroup\$
1
  • \$\begingroup\$ hah, nicely done! \$\endgroup\$ Commented Nov 22, 2014 at 13:15
1
\$\begingroup\$

Python, 28, by user3863227

print(int(bin(1234)[2:])**2) 

Factorizing the output gave this one away quite easily:

100220321420320200100 = 2² × 5² × 457² × 2190593² sqrt(100220321420320200100) = 10011010010 int('10011010010',2) = 1234 
\$\endgroup\$
1
\$\begingroup\$

Perl - 26 bytes by primo

f:print po=>glob q$t{a,o}$ 

The q was easy to recognise. I took the potato letters away and shuffled the rest to discover glob suddenly. Then, I realised $$ will be used instead of {} and that => can be created. The last thing was f:, it took me a while to think of a label.

\$\endgroup\$
1
  • \$\begingroup\$ You should have commented on my answer! I didn't see this til now. \$\endgroup\$ Commented Dec 4, 2015 at 2:13
1
\$\begingroup\$

CJam, 14, by User23013

92e8.17 5e6.3% 

I started by making some assumptions: that the exponent in each case was a floating point number, and that it had at least one digit after the dot (otherwise it's just the same as using an integer) and one or two before it (otherwise the result would be too small or too large). Then I used Python's itertools library to do some permutations. I got a result in under a minute.

Here's my cracking code:

from itertools import permutations target = 108183.05975155532 def e(mantissa, exponent): return mantissa * 10 ** exponent def ePartition(digits): """Generator function: gives every way to partition digits into an integer mantissa and a floating point exponent that is > 1 and < 100.""" for eIndex in range(1, len(digits) - 1): for dotIndex in range(eIndex + 1, min(len(digits), eIndex + 3)): yield (digits[:eIndex], digits[eIndex:dotIndex] + "." + digits[dotIndex:]) for p in permutations("12356789"): for spIndex in range(3,6): digList1 = "".join(p[:spIndex]) digList2 = "".join(p[spIndex:]) for mant1, expt1 in ePartition(digList1): for mant2, expt2 in ePartition(digList2): value = eval("e(%s,%s)%%e(%s,%s)" % (mant1, expt1, mant2, expt2)) if value == target: print("%se%s %se%s%% -> %s" % (mant1, expt1, mant2, expt2, value)) 
\$\endgroup\$
1
\$\begingroup\$

JavaScript, 36, by MegaTom

x=alert;x(("x"+x)["substring"](6,9)) 

Tested in Chrome's console.

\$\endgroup\$
1
\$\begingroup\$

Python 2, 13, by mbomb007

71e0//36/0x92 

The output is 0.00684931506849315 on my machine. But it worked on http://repl.it/.

\$\endgroup\$
5
  • \$\begingroup\$ It blows me away that there can be more than one solution! I'll post the original source tomorrow, since I can't remember it (I wrote it down). \$\endgroup\$ Commented Jan 5, 2015 at 1:51
  • \$\begingroup\$ Actually, it's probably only because I used integer division. Nvm. \$\endgroup\$ Commented Jan 5, 2015 at 1:52
  • \$\begingroup\$ I'm curious though, you did crack it with a program in Python, right? \$\endgroup\$ Commented Jan 5, 2015 at 1:54
  • \$\begingroup\$ @mbomb007 No. It's easy to know the number is 1/146. Then just try to get a 1. There are other solutions like 1e3//760/0x92. \$\endgroup\$ Commented Jan 5, 2015 at 4:13
  • \$\begingroup\$ Original code: 6e1//073/0x92 \$\endgroup\$ Commented Jan 5, 2015 at 14:35
1
\$\begingroup\$

Python, 39 bytes, Reticality

print("{0}{2}{1}{1}{1}".format(0,5,6,)) 

You could also swap the {0} & {2} and the 0 and 6.

\$\endgroup\$
1
\$\begingroup\$

JavaScript, 15, by Jamie Barker

Math.sin(1)+'O' 

EZ PZ, as you said. ;)

\$\endgroup\$
1
\$\begingroup\$

Python, 13 bytes, by Reticality

To be run on an interactive Python console:

len("printi") 

Outputs 6.

\$\endgroup\$
1
\$\begingroup\$

CMD, 9, by unclemeat

set/a!!!0 

There are too few possibilities here. The 4 alphabet characters are most likely command name, so I attack in that direction.

\$\endgroup\$
1
  • \$\begingroup\$ I was going for minimal byte count - here is a longer answer, but probably more difficult off the bat. \$\endgroup\$ Commented Jan 13, 2015 at 5:51
0
\$\begingroup\$

Bash, size 23, by The Wolf

q=echo;_(){ $q $q;};""_ 

I think the original solution (or red herring) should be:

q(){ q=;};q ""echo;$_ $_ 

which is invalid because it has one more space character.

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

C, size 63, es1024

main(_){int __=_;_<<=_;__=_<<_<<__;printf("%d",_<<__|__);_|__;} 

What I'm trying to get is 2 << 16 | 16. Three leftover underscores, woohoo.                                    

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

Rust, size 123, by Vi.

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

This shouldn't be the intended solution because of the no-op for loop, but it produces no warning in play-pen anyway.

(I'll leave the Clojure part for others.)

\$\endgroup\$
2
  • \$\begingroup\$ It may happen that the "hint" part whould be the hardest to crack... \$\endgroup\$ Commented Nov 13, 2014 at 22:32
  • \$\begingroup\$ Welcome to version 2 of this task. \$\endgroup\$ Commented Nov 13, 2014 at 22:53
0
\$\begingroup\$

PHP, 62, aks.

for($i=1;$i<3.;)echo"$i. ".((($i++==2))?'Tues':'Mon').'day '; 

Quite easy compared to other crazy PHP submissions.

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

JavaScript, 24 bytes (by fogcityben)

'.+';console.log( 'hi' ) 

Not sure what he really did with that . and +.

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

Python 3, 21 bytes, Reticality

print(str(...)[4::2]) 

Prints the p and final i from Ellipsis.

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

Python, size 26, by Oliver

print 2 * 3 * 37037, print 

The 2 prints threw me off a bit.

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

Python, size 15, by mbomb007

There are at least 5 permutations that work. This is one of them:

`3*.7/50`[::~4] 

It was pretty obvious that the original code was something of the form `«expression»`[«range»], so it wasn't difficult to place the backticks, colons and square brackets. On a hunch, I assumed that the range specifier was [::~i] for some value of i, leaving only 8 characters to permute. This took only a fraction of a second. Here's the code I used:

from itertools import permutations perms = [''.join(p) for p in permutations('03457*./')] for p in perms: try: e = '`'+p[:-1]+'`[::~'+p[-1:]+']' if eval(e)=='6991': print e except: continue 

(The original code is actually a bit flakey, since the result of 3*.7/50 isn't guaranteed to be 0.041999999999999996 all of the time.)

\$\endgroup\$
1
  • \$\begingroup\$ Yep. For some reason, it wouldn't let me use *2 after the code enclosed in backticks... I couldn't find anything about why not. It works fine if it's after a literal string, or str(expr)... \$\endgroup\$ Commented Jan 13, 2015 at 17:31
0
\$\begingroup\$

Python, size 30, by mbomb007

Didn't need much unscrambling:

' rsin[~(ddf) 0]rot13'[9+6: :] 
\$\endgroup\$
5
  • \$\begingroup\$ :O #Mindblown... That's not even close to the original concept... \$\endgroup\$ Commented Jan 13, 2015 at 17:35
  • \$\begingroup\$ I'm going to remove a character to make it harder. \$\endgroup\$ Commented Jan 13, 2015 at 17:36
  • \$\begingroup\$ Wait, I found a way to remove your workaround! I'll post the new one! \$\endgroup\$ Commented Jan 13, 2015 at 18:02
  • \$\begingroup\$ codegolf.stackexchange.com/a/44514/34718 \$\endgroup\$ Commented Jan 13, 2015 at 18:08
  • \$\begingroup\$ I posted the solution. \$\endgroup\$ Commented Jan 20, 2015 at 20:08
0
\$\begingroup\$

CMD, 21, by unclemeat

set /a!!"echo>>tfile" 

Repeating the set /a trick and ! operator is reducing the search space for otherwise a tough nut to crack.

I'm not too sure how set /a works, but when I evaluate set /a "tfile", it returns 0. Not sure if all strings evaluates to 0, but in this case, we end up evaluating (!!0) >> 0, which is 0.

\$\endgroup\$
2
  • \$\begingroup\$ I figured doing the same trick would be too obvious. However you were slightly off the mark to what I had in mind. I evaluate two separate strings with ! (negation), each producing 1 - then perform a logical shift >> on the two values - which produces 0. Nice one. \$\endgroup\$ Commented Jan 13, 2015 at 21:37
  • \$\begingroup\$ @unclemeat: I think you should explain your own version in your post. We typically don't change our answer to be the same as the original answer. Anyway, nice to know about the explanation. \$\endgroup\$ Commented Jan 14, 2015 at 2:35
1
3 4 5
6
7

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.