# 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

# 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/; }'
• Now try to find the original solution. Maybe I'll manage to change the task, so easy way whould stop working. – Vi. Nov 12 '14 at 14:51

# DC, 28 bytes, by MichaelT

[ls+dn11ls1+dss<n]sn1ss0lnx

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

• Off by one error in my counting. But yep. You got it. My original version was: 1ss[lsd1+ss+dn11ls<n]sn0lnx – user12166 Nov 13 '14 at 23:20
• 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? – user12166 Nov 13 '14 at 23:44
• @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. – jimmy23013 Nov 14 '14 at 0:51

# CJam, 51, by Optimizer

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

# Python, 45, by muddyfish

print(eval((chr(32)+chr(45)).join(str(413))))

Interesting idea, I have to say. Wasn't hard to brute force though.

• I ended up with print(chr(int(45+3.)))or((((acehjlrsv1234)))). I think yours looks a bit neater :-) – squeamish ossifrage Nov 14 '14 at 2:55

## Brainfuck, 39, by Mig

+++++++[->++++++<]>[->++<]>-.----.++++.
• Nice ! Original : +++++[>++++[>++++<-]<-]>>+++.----.++++. – Michael M. Nov 14 '14 at 10:19
• Huh, and I thought I had matched your program perfectly. Neat how the characters used ended up exactly the same, then. – FireFly Nov 14 '14 at 11:49
• Yeah I was pretty surprised too. – Michael M. Nov 14 '14 at 12:48

# 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]));
}
• Different from my original, but that's not surprising. How did you brute force it? Did you just count up? – xnor Nov 15 '14 at 7:05
• @xnor I added the code I used to the answer – es1024 Nov 15 '14 at 7:05
• I made a new bigger version. Happy cracking. – xnor Nov 15 '14 at 10:27

# 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.

# C++, 244 bytes?, by Gabe Evans

#include<iostream>

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

e9-i|yig9s pre

# C, size 62, by Olavi Mustanoja

#include<stdio.h>
#define _ +8
int*main(){printf("%d",1 _ _);}
• hah, nicely done! – Olavi Mustanoja Nov 22 '14 at 13:15

# 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

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.

• You should have commented on my answer! I didn't see this til now. – primo Dec 4 '15 at 2:13

# 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))

# JavaScript, 36, by MegaTom

Tested in Chrome's console.

# Python 2, 13, by mbomb007

71e0//36/0x92

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

• 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). – mbomb007 Jan 5 '15 at 1:51
• Actually, it's probably only because I used integer division. Nvm. – mbomb007 Jan 5 '15 at 1:52
• I'm curious though, you did crack it with a program in Python, right? – mbomb007 Jan 5 '15 at 1:54
• @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. – jimmy23013 Jan 5 '15 at 4:13
• Original code: 6e1//073/0x92 – mbomb007 Jan 5 '15 at 14:35

# 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.

# JavaScript, 15, by Jamie Barker

Math.sin(1)+'O'

EZ PZ, as you said. ;)

# Python, 13 bytes, by Reticality

To be run on an interactive Python console:

len("printi")

Outputs 6.

# 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.

• I was going for minimal byte count - here is a longer answer, but probably more difficult off the bat. – unclemeat Jan 13 '15 at 5:51

# Python, size 68, by horns

o=ord;print(chr(35),o('{'),o("-"),o("C"),o("Y"),sep="")#''''"02blpst

I think I've got the characters right. Either way, if I miscounted the number of quotes, the rest go after the comment (consulting the ASCII table helped).

# 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.

# C, size 63, es1024

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

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

# 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.)

• It may happen that the "hint" part whould be the hardest to crack... – Vi. Nov 13 '14 at 22:32
• Welcome to version 2 of this task. – Vi. Nov 13 '14 at 22:53

# PHP, 62, aks.

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

Quite easy compared to other crazy PHP submissions.

# JavaScript, 24 bytes (by fogcityben)

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

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

# Python 3, 21 bytes, Reticality

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

Prints the p and final i from Ellipsis.

# Python, size 26, by Oliver

print 2 * 3 * 37037,
print

The 2 prints threw me off a bit.

# 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.)

• 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)... – mbomb007 Jan 13 '15 at 17:31

# Python, size 30, by mbomb007

Didn't need much unscrambling:

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

# 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.

• 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. – unclemeat Jan 13 '15 at 21:37
• @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. – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Jan 14 '15 at 2:35