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

  • 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

2 3 4 5

CJam, size 20, by Martin Büttner

Hi "petStorm!", mame

Try it online.

How it works

Hi                      "           int(17)                     ";
   "petStorm!",         "                    len('petStorm!')   ";
                ma      "     atan2(       ,                 )  ";
                  me    " exp(                                ) ";
                        " exp(atan2(int(17), len('petStorm!'))) ";

Cracking the code

The desired output, 2.956177636986737, is either a Double or a Double followed by a Long.

Using only the characters in "Stop, Hammer time!", there are four builtin operators that return non-integer Doubles:

  • mS, which is asin
  • ma, which is atan2
  • me, which is exp
  • mt, which is tan

All of them contain an m, so we can use at most three of them. There is only one S and one a.

All of those operators need input, and ma is the only one that consumes two inputs. We have only three ways to push Longs:

  • "...",, which pushes the string's length (strictly less than 18).
  • H, which pushes 17.
  • ...!, which pushes the logical NOT of ....

We have no way of pushing something falsy as ..., so the last option will always push 0.

The output doesn't begin or end with 17 or 0. Since 15 decimal digits is the usual number of digits for a Double, it seemed likely that the output was a simple Double.

Assuming this, the code has to fall in one of the following categories:

  • <Long> <mS|me|mt>{1,3}
  • <Long> <mS|me|mt>{x} <Long> <mS|me|mt>{y} ma <mS|me|mt>{z}.
  • Any of the above, with some cast to Long (i) or rounding (mo) applied to a Double.

In the second case, x + y + z is either 1 or 2 and one of the Longs is 0 or 17.

The rest was basically brute force. After a few tries,

18 , {H \ ma me 2.956177636986737 =} =

returned 9, meaning that

H 9 ma me

produces the desired output.

All that's left is to eliminate all but 9 characters from the string. Spaces are noops and i is a noop on Longs, so "petStorm!" is one of the possible choices.

  • 1
    \$\begingroup\$ That's insane - how did you figure out what the number was? \$\endgroup\$
    – Sp3000
    Commented Nov 6, 2014 at 4:14
  • 1
    \$\begingroup\$ I searched the logarithm (and others) of that number but didn't get any result. Now I found I was using too high precision. \$\endgroup\$
    – jimmy23013
    Commented Nov 6, 2014 at 4:32
  • 2
    \$\begingroup\$ @Sp3000: I've edited my answer. \$\endgroup\$
    – Dennis
    Commented Nov 6, 2014 at 4:52
  • 1
    \$\begingroup\$ Very nice! I should have taken out two more characters from the string I guess. In my original I actually had the spaces still inside the string, but an mr before taking the length. Not that you wouldn't have figured that out as well at some point. ;) \$\endgroup\$ Commented Nov 6, 2014 at 10:30

Python 3, size 12, by xnor

()and bciprt

Does nothing (expression produces an empty tuple, which is not printed). This works due to short-circuit evaluation.

  • 1
    \$\begingroup\$ In Python 3 IDLE, this outputs (). \$\endgroup\$
    – user10766
    Commented Nov 4, 2014 at 21:14
  • \$\begingroup\$ @hosch250 Since its in a program (a python file), nothing is outputted, as there is no print. \$\endgroup\$
    – matsjoyce
    Commented Nov 4, 2014 at 21:15
  • \$\begingroup\$ I see. I was running from the command line thing. \$\endgroup\$
    – user10766
    Commented Nov 4, 2014 at 21:16
  • 49
    \$\begingroup\$ ...."thing".... \$\endgroup\$
    – TheDoctor
    Commented Nov 4, 2014 at 23:21
  • 4
    \$\begingroup\$ @Imray Because of short-circuiting - Python loads the tuple and checks if the tuple's value is true, since it's empty, it is false. The code to load the variable bciprt is never executed, so it never produces a NameError. \$\endgroup\$
    – Mateon1
    Commented Nov 10, 2014 at 14:13

Python, size 74, by xnor

any(print(set is
set)for i in oct(chr is
map))and aeeeeeggiilnnpprrrrrstvw

Well that was fun. Thanks to FryAmTheEggman, hosch250 and isaacg for suggestions/helping out.

  • 1
    \$\begingroup\$ Nice job! My solution was quite similar: list(\nprint(range is range)for aacdeeeeehmppprrrrssvwy in\noct(int is int)). \$\endgroup\$
    – xnor
    Commented Nov 7, 2014 at 1:46
  • 1
    \$\begingroup\$ @xnor LOL that variable name. Is it bad that I would have never thought of that? :P \$\endgroup\$ Commented Nov 7, 2014 at 2:23
  • 2
    \$\begingroup\$ @FryAmTheEggman I think everyone was expecting me to use the trick from my first cop. \$\endgroup\$
    – xnor
    Commented Nov 7, 2014 at 2:24
  • \$\begingroup\$ @FryAmTheEggman Don't worry, you're not the only one :P \$\endgroup\$
    – Sp3000
    Commented Nov 7, 2014 at 2:25

Python 2, size 50, by Geobits

print 2**2**2*2**2-22-2**2**2**2/2**2**2**2**2/2/2

Outputs 42.

  • 1
    \$\begingroup\$ Have a point :) For reference, original was print 2**2**2**2/2**2**2/2**2**2/2-2**2**2*2**2-22, but it's not surprising at all that more than one option is correct. \$\endgroup\$
    – Geobits
    Commented Nov 4, 2014 at 20:33

GolfScript, size 13, by Peter Taylor


Test it here.

Another one, that I only cracked with big help from Sp3000. Thanks!

So here's how we got there. Sp3000 noticed a bunch of runs of consecutive numbers in the output:


Based on that we made the assumption, that this was an increasing sequence, which only allowed for one possible splitting of the remaining numbers:


That's 23 numbers, which was a strong indicator for repeating the block 22 times, as well as ending the block with . (duplicate top stack element), such that the previous result got left behind on the stack and such that the final iteration would appear on the stack twice. That's 22,{____.}/.

Now looking at the gaps, those turn out to be 4th powers (which is nice, because we have 4 and ?). More precisely, they are the fourth power of the index of the current number. So next we looked at which indices created a gap:

4,5,6,7, 12,13,14,15, 20,21,..?

In binary those are


They all have the third bit set, which means that the index is probably just bitwise-and'ed with 4 (which is nice again, because we can make another 4 with . and have a &). This works particularly well, because this operation results in either 0 or 4, and if we use that as the exponent we get either 1 or a fourth power, which is exactly what we need. So let's put that together:


Here is what the block does:

.      # Duplicate current index
 4     # Push a 4
  &    # Bitwise and
   ?   # Raise index to resulting power
    +  # Add to previous result
     . # Duplicate for use in next iteration

Now there were two problems left: we had a stray , we didn't use yet, and the first iteration is a special case, in that there is no value from a previous iteration which we could add things to when encountering +. We found that thanks to an unrelated comment by user23013 who casually mentioned that GolfScript starts out with an empty string on the stack (if there's nothing on STDIN). So we could use that other , right at the beginning to turn that string into a 0, which was just what we needed as the start of the iteration.

  • \$\begingroup\$ Spot on. This was inspired by a sequence in OEIS which I can't find now. \$\endgroup\$ Commented Nov 6, 2014 at 12:29
  • 3
    \$\begingroup\$ And this is why having a separate thread for robbers is a good idea. Nice job! \$\endgroup\$
    – Dennis
    Commented Nov 7, 2014 at 3:52

Python 3, size 16, by matsjoyce

import __hello__
  • 1
    \$\begingroup\$ Bah, beaten by 20 seconds >< \$\endgroup\$
    – Geobits
    Commented Nov 4, 2014 at 21:17
  • \$\begingroup\$ Correct, one point to you (should we have a list with this info on it too?) \$\endgroup\$
    – matsjoyce
    Commented Nov 5, 2014 at 7:39

Ruby, size 17, by Doorknob

p 2,%r~n~i=~'*tN'

That was great fun. Thanks to Sp3000 for helping me out with this! And I learned that %r?...? literals can have any delimiters. :)

  • 10
    \$\begingroup\$ Props to Doorknob for being insanely misleading with print, only to split it up into p for printing, %r for regexes and i for case-insensitive regex matching. \$\endgroup\$
    – Sp3000
    Commented Nov 5, 2014 at 19:15

PHP, size 49, by bwoebi

print@substr(new exception,+~$$a+=++$$m+$$i+2+n);

That was absolutely mental.

It got to

print@substr(new exception,);

fairly quickly, at which point I needed something that gives -6 after the comma, having $++$++$++$+=$~main$2 left.

The main catch is that $a, $m and $i are all NULL, so using them indirectly in variable variables, means they all point to the same variable. However, PHP seems to be doing some weird things about resolving variable variables. With normal variables you can do things like

echo $a+$a=2;

which prints 4 (the 2 is assigned to $a and then added to itself). But if I do the same with variable variables:

echo $$a+$$a=2;

I get 2, because now the first $$a is evaluate before the assignment.

In the end I managed to force some order by putting some increments on the RHS of the += which had to be evaluated before that addition-assignment. That way I got to 5 which I could then just bit-complement. Still... there are some mysterious things going on, and I have no idea why half the things I tried worked and didn't work.

  • \$\begingroup\$ For reference, my original: print@substr(new exception,~$$mn+=2+$$a+++$$i++); \$\endgroup\$
    – bwoebi
    Commented Nov 6, 2014 at 1:54
  • \$\begingroup\$ Btw. I hope all the dollar signs and the fact that all the letters for main were in the string mislead you a lot. Also, a rather unusual method for extracting {main}, I think ;-) \$\endgroup\$
    – bwoebi
    Commented Nov 6, 2014 at 1:58
  • \$\begingroup\$ @bwoebi The main didn't really mislead me, after spotting exception, new and substr. I thought they would just be variable names. It took me a bit to come up with using variable variables and than I spent most of the time on figuring out some order of operations that would actually yield a 5 which I could complement without using another set of parentheses. \$\endgroup\$ Commented Nov 6, 2014 at 2:01
  • \$\begingroup\$ Well, for next time, if there are more dollars than characters, it usually are variable variables. (In this case I also abused varvars to force left-to-right evaluation.) How long did it take you then to spot the substr new exception? Also by the way, I have deeper knowledge of the Zend engine, so I can perfectly explain to myself why things are evaluated in which order and that's nice for these challenges ;-) If there's a specific thing you don't get, I'll happily explain it to you. \$\endgroup\$
    – bwoebi
    Commented Nov 6, 2014 at 2:08
  • \$\begingroup\$ @bwoebi Come in chat tomorrow, and we can talk about it, but I've spent long enough on this today. ;) As for your first question, exception was obvious, which left stray characters for substr and new lying around. It was literally the first thing I saw when starting to work on it. \$\endgroup\$ Commented Nov 6, 2014 at 2:12

Ruby, size 38, by Doorknob


I'm pretty sure this is nowhere near the original source. It's deterministic despite using rand.

Here is how this one works. $><< is just output. $pece60 and $win are undefined global variables, which therefore are just nil (and they allowed me to get rid of some extraneous characters). !$pece60 makes a true and to_s gives the string "true".

For ages, I tried getting a 2 or -2 to access that u in there, but then I realised I could just take the t, and call .succ(essor) on it to make a u.

rand with a nil parameter returns a random float in the interval [0,1). When using floats to index into strings, they get truncated to integers, so this will always return the first character.

Finally, I had a spare pair of [] so I just wrapped everything in it, because thankfully everything is an expression in Ruby.

Thanks to Sp3000 for throwing some ideas around in chat.

  • 9
    \$\begingroup\$ Ruby is a scary-looking language. \$\endgroup\$
    – feersum
    Commented Nov 8, 2014 at 14:16

C, 51 by es1024

c=0xf.cp9,hhtaglfor;main() {;; printf("%d",(++c));}

After 20 years of programming C today I learned about hexadecimal floating point constants.


Ruby, 45 (histocrat)

%q[zyfnhvjkwudebgmaclprs x].to_i(36)/51074892

Woohoo! This is my first crack at a code golf problem, and I don't have enough rep to comment on the original post. I immediately recognized the trick used, since I've actually found use for it in production code often. It took about 5 minutes to figure out most of the structure and a few hours to come up with the complete answer.


  • %q[] is an alternative method for creating strings. Parenthesis and curly braces may also be used.
  • String#to_i in Ruby accepts numbers in any base from 2 to 36. It will ignore the first character in the string which is not part of the number, so any extra characters can be "thrown away" after the space.

And here's the code I used to crack it:

require 'set'

# return true if the string is made up of unique characters
def uniq(s)
  a = s.each_char.to_a
  return a == a.uniq

def uniq_while_same(a,b)
  s = Set.new
  a.each_char.zip(b.each_char).each do |ai, bi|
    return true if ai != bi
    return false if s.include? ai
    s << ai
  return true

def ungolf(answer)
  # For each base that even makes sense
  [            36, 35, 34,     32, 31, 30,
   29, 28, 27, 26, 25, 24, 23,     21, 20,
   19, 18, 17, 16, 15, 14, 13, 12,     10].each do |base|
    # Ignore bases where it is not possible to create a unique-string number greater than answer
    next if answer > base ** base
    # Pick digits for the denominator that are not duplicates of the digits in base
    denominator_digits = ('1234567890'.each_char.to_a - base.to_s.each_char.to_a)
    # For each permutation of those digits for the denominator
    (1..10).each do |denominator_length|
      denominator_digits.permutation(denominator_length) do |denominator_s|
        # Maybe the denominator is in octal
        denominator_base = 10
        if denominator_s[0] == '0'
          next if denominator_s.include?('8') || denominator_s.include?('9')
          denominator_base = 8
        denominator_s = denominator_s.join
        denominator = denominator_s.to_i denominator_base
        print "#{"\b"*64}(%q[#{(answer * denominator).to_s(base).ljust(36)}].to_i #{base})/#{denominator_s.ljust(10)}" if rand < 0.01
        # Ignore denominators that are definitely impossible to have answers for
        next unless uniq_while_same "qtoi#{base}#{denominator_s}#{(answer * denominator).to_s(base)}",
                                    "qtoi#{base}#{denominator_s}#{((answer + 1) * denominator).to_s(base)}"

        # For each numerator that gives answer when divided by the denominator
        (answer * denominator...(answer + 1) * denominator).each do |numerator|
          print "#{"\b"*64}%q[#{numerator.to_s(base).ljust(36)}].to_i(#{base})/#{denominator_s.ljust(10)}" if rand < 0.01
          # Remove any that are still not unique
          s = "#{numerator.to_s(base)}#{base}#{denominator_s}qtoi"
          next unless uniq s
          # Done. Compute which characters need to be thrown away to fill the remaining space
          remains = ('0123456789abcdefghijklmnopqrstuvwxyz'.each_char.to_a - s.each_char.to_a).join
          print "#{"\b"*64}#{" "*64}#{"\b"*64}"
          return "%q[#{numerator.to_s(base)} #{remains}].to_i(#{base})/#{denominator_s}"
  print "#{"\b"*64}"
  puts "\nnone"
  return nil

print ungolf 9410663329978946297999932

Way to go embedding an NP problem inside a riddle. I have been thoroughly nerd-sniped. Good job!

  • \$\begingroup\$ I added a comment to the original answer for you. \$\endgroup\$
    – FireFly
    Commented Nov 14, 2014 at 20:44
  • \$\begingroup\$ This is awesome (and close to the intended answer), but technically not valid because it doesn't have output. \$\endgroup\$
    – histocrat
    Commented Nov 14, 2014 at 20:59
  • \$\begingroup\$ *facepalm Well I still had fun. \$\endgroup\$ Commented Nov 14, 2014 at 21:29
  • 2
    \$\begingroup\$ @charredUtensil if you don't mind running your script for some more, I think the printing is just moving the p to before the expression. Presumably the remaining characters can be used to form the constants as you've done. \$\endgroup\$
    – FireFly
    Commented Nov 14, 2014 at 21:34
  • \$\begingroup\$ I don't actually need to run it again. The last few characters of the string can be rearranged without changing the result - p %q[zyfnhvjkwudebgmaclrsx].to_i(36)/51074892 I know I broke my actual cracking attempt though :) \$\endgroup\$ Commented Nov 15, 2014 at 6:32

Python [any] shell size 44, by Caridorc

__name__[3]  or (enfin_____[42], manager[1])

I'm sure there was supposed to be more to it than this, but since __name__ equates to __main__, the 4th character 'a' is selected and the rest of the line is never evaluated.

  • \$\begingroup\$ Just for reference the original programme is [__name__ for ___name__ in range(1,4)][2][3] \$\endgroup\$
    – Caridorc
    Commented Nov 5, 2014 at 12:47

Perl, size 36, by squeamish ossifrage


Another difficult one.

  • 1
    \$\begingroup\$ Well done :-) That's it exactly. \$\endgroup\$
    – r3mainer
    Commented Nov 6, 2014 at 10:03
  • \$\begingroup\$ @squeamishossifrage Thanks. You had some very nice 'Perl features' hidden in that program. \$\endgroup\$
    – grc
    Commented Nov 6, 2014 at 10:22

CJam, size 13, by user23013


Test it here.

Solved by hand, like so:

First, some background for non-CJammers:

  • CEGIK are all variables, which are pre-initialised to 12, 14, 16, 18, 20, respectively.
  • s converts the top stack element to a string.
  • Strings are technically just arrays of characters.
  • f is pretty magic. For the purpose of this answer, the simplified version is that, for an array a, some other value b and an operator g, the sequence abfg maps g(_,b) onto a (where each element of a goes into the _ slot).
  • / is division and splitting arrays (amongst other things).
  • * is multiplication and array repetition (amongst other things).
  • % is modulo and some weird operation, which in the form ad% for array a and integer d takes every dth element of a (like Python's slicing with step width d).
  • # is exponentiation (amongst other things).
  • , turns numbers into ranges (from 0 to n-1) and returns the length of an array.

Okay, that out of the way...

It was fairly obvious that we needed , to turn a number into a range, because the only other way to get an array would have been to build a larger number and turn it into a character array with s - but then we couldn't have done any further arithmetic on it. And we need an array to do something with the fs.

I first assumed that the fs were used with # and %, but that would mean we would have needed a number around 90 to get the right amount of digits in the end. And also, this didn't explain what to do with s, and since the answer looked really golfy, I doubted user23013 just appended an s as an effective no-op somewhere to throw people off.

So I figured, maybe he isn't even keeping the numbers small with %, but instead he builds an array of huge numbers, concatenates their string representation with s, but then only picks some odd slice out of it with %. So I played around a bit with the following framework:


(You can't do _f/ first, because that would yield zero for at least the first 12 elements.)

Where the _ are some permutation of the variables. I didn't try all of them before I got bored, and the main problem with this was that the resulting sequence of digits as always way too long.

At some point it occurred to me, that we wouldn't need such a large range (i.e. the product of two numbers), if instead we used the * to repeat the resulting string. Due to the mismatch of the parameters of * and % this would yield no repetition in the result:


This yielded results of a length very close to what I was looking for. I would have actually tried all 240 of them, but fairly quickly (third or fourth attempt), I stumbled upon


which yields


And I figured a match of the first six digits wouldn't be a coincidence. So the question was how to rearrange it without upsetting the actual computation:

  • I couldn't change K because that would pick out different digits altogether.
  • I couldn't change C or I because that would change the numbers resulting from the two map operations.
  • If I changed G that would only change the number of repetitions, which would do nothing but change the length of the result. (Which is good.)
  • If I changed E that would change the range of the array, but the range would still start with [0 1 2 3 ...], so it wouldn't affect the calculation. It would affect the length of the base string returned by s, which would also mean that K% would pick out different digits upon additional repetitions.

So I just tried swapping E and G and voila:


In summary, here is what the code does:

G,            "Push [0 1 2 3 ... 13 14 15].";
  Cf#         "Raise each element to the 12th power.";
     If/      "Divide each element by 18.";
        s     "Concatenate all numbers into a string.";
         E*   "Repeat 14 times.";
           K% "Pick every 20th digit.";

APL, size 17, by user23013

+(3*3)3,(***)\3 3

I spent far too long trying to crack this. It probably would've gone quicker if I knew APL going in.

Try it out here


Pyth, size 11, by isaacg

:\\w$ ",d,N

That's some mean bug abuse right there. This compiles to:

Pprint("\n",at_slice("\",input(), ",d,N))

The relevant bug is that \\ compiles to "\" instead of "\\", which lets you compile Pyth into a string.

  • \$\begingroup\$ Should the Pprint be print, or at least pprint? \$\endgroup\$
    – FireFly
    Commented Nov 15, 2014 at 0:56
  • \$\begingroup\$ @FireFly That's what the debug output stated. Maybe the Pyth interpreter defines its own Pprint? \$\endgroup\$ Commented Nov 15, 2014 at 0:57
  • \$\begingroup\$ Oh, okay, never mind then. \$\endgroup\$
    – FireFly
    Commented Nov 15, 2014 at 0:59

Python, size 69, by Sp3000


That was hard...

  • 1
    \$\begingroup\$ Nice! For reference, the original was print(sum(map(ord,str((dict(list(((str(),str(dict())),))),list()))))), but obviously a lot of different permutations of keywords would work. \$\endgroup\$
    – Sp3000
    Commented Nov 5, 2014 at 13:01
  • 2
    \$\begingroup\$ That's a LISP-level of parens there! \$\endgroup\$
    – xnor
    Commented Nov 7, 2014 at 2:16

Python 3, 37 bytes, by Sp3000


Embarrassingly by far the hardest part was figuring out to convert the string into bytes. I had to sleep on it, and in the night realized 'duh, it's a bytes literal!'

  • \$\begingroup\$ Ahaha nicely done, I thought the Ellipsis might trip people up but I guess not \$\endgroup\$
    – Sp3000
    Commented Nov 8, 2014 at 0:20
  • \$\begingroup\$ I saw the ellipsis and zfill, but didn't know about the bytes objects. Those could be useful in golfing arrays of integers! \$\endgroup\$
    – feersum
    Commented Nov 8, 2014 at 0:22
  • \$\begingroup\$ Great job! I only saw the print and the .zfill, and I knew sum might be part of it, but I couldn't solve it. Have a +1. \$\endgroup\$
    – user10766
    Commented Nov 8, 2014 at 0:40

PHP, 53, by PleaseStand

Cracked it at last:


The solution came quite quickly when I noticed that the sequence consists of alternating decimal and octal numbers:

Dec: 57...92...132...177...228...285...348...417...492....573....661....756....858....
Oct: ..134..204...261...344...435...534...641...754...1075...1225...1364...1532...1707
==Dec:  92  132   177   228   285   348   417   492    573    661    756    858    967

Also, the intervals between each set of numbers grew at a rate equal to the value returned by printf() (i.e., the number of characters written).

  • 3
    \$\begingroup\$ Wow, nice detective work! \$\endgroup\$
    – Sp3000
    Commented Nov 8, 2014 at 15:28

Python 2, size 132, by Vi.

exec('from string import printable as e\nprint "cqance"\x2Ereplace("q",e[len("fgiillmmooprrsstt")])or ",,,\016:::S[]____tuuvyy" ""')

Thanks for all the backslashes and quotation marks :)

Edit: The updated 96-char version:

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

This is taken entirely from Alex's solution in https://codegolf.stackexchange.com/a/41451/32353

  • \$\begingroup\$ Heh, nice. Wondering what the indended solution was... \$\endgroup\$
    – FireFly
    Commented Nov 12, 2014 at 23:28
  • \$\begingroup\$ This is not an intended solution. The original solution does not have any "throw-away" things like fgiillmmooprrsstt or ,,,\016:::S[]____tuuvyy. \$\endgroup\$
    – Vi.
    Commented Nov 13, 2014 at 12:34
  • \$\begingroup\$ exec? My code chould have been shorter... I was emulating it with compile+eval because of I forgot about exec... \$\endgroup\$
    – Vi.
    Commented Nov 13, 2014 at 12:36
  • \$\begingroup\$ Implemented the shorter version. Try to figure out the original trick. \$\endgroup\$
    – Vi.
    Commented Nov 13, 2014 at 12:42

CJam, size 15, by Ypnypn


From the given characters, I guessed it had to be one of the three following forms:


which creates a two-digit range, then maps an addition and modulo operation (in either order) onto the range, before summing it. So I just started with the first one, and systematically tried permutations of 6789 in the gaps.

  • \$\begingroup\$ Dammit, I just solved it too :/ \$\endgroup\$
    – Optimizer
    Commented Nov 4, 2014 at 21:45

PHP, size 52, by PleaseStand

for(mt_srand($i=46);$i--;)echo chr(mt_rand()%95+32);

This turned out to be quite easy in the end. The output looks very random, and the characters m, t, _, r, a, n and d all appeared twice...


Python 2, size 61, by FryAmTheEggman


I'd be very surprised if this matches the original.

  • \$\begingroup\$ It doesn't, but congrats anyways! My code was:print''.__doc__[::2][::3].split()[1].split('.')[0][:-~-~True] \$\endgroup\$ Commented Nov 5, 2014 at 4:56
  • \$\begingroup\$ In hindsight, I shouldn't have included the quotes... ;) \$\endgroup\$ Commented Nov 5, 2014 at 4:59
  • \$\begingroup\$ @FryAmTheEggman Oh wow - nice program! I was convinced you had at least used dir() to find the 'get'. And yes, it would have been very difficult without the quotes. \$\endgroup\$
    – grc
    Commented Nov 5, 2014 at 5:04

Python 3, Sp3000, size 44


Python 3 helped me here as I was able to cause an error (left-shifting None by something) after printing the answer.

  • \$\begingroup\$ Hmm... looks like I was pretty wasteful with my parens. Had print(~(~(()<())<<((()<((),))<<(()<((),))))) originally. \$\endgroup\$
    – Sp3000
    Commented Nov 5, 2014 at 13:49

PHP, size 52, by kenorb

_:@print_r(chr(@++$i+pow(3<<5,1)));if($i<2*4)goto _;

(God, how long it took me to figure what to do with the remaining _r suffix. Until I noticed it was not print, but print_r...)

  • \$\begingroup\$ And I don't know how did you figure it out:) Original: _:print_r(chr(3*pow(2,5)+@++$i));if(@$i<4<<1)goto _;. \$\endgroup\$
    – kenorb
    Commented Nov 5, 2014 at 18:38
  • 3
    \$\begingroup\$ @kenorb a) you need to print something, so echo not possible; print remained; b) you need some loop, but for a for loop, there weren't enough semicolons, and well, there's a colon... so probably a label there in combination with goto; c) then it needs an if to abort the goto-loop. Having now X:print($Y);if($Y)goto X; (X and Y being placeholders); d) there's a ++, but no =, so probably some ++$Z from 1 to 8; e) to get letters from an integer, we need chr() (usually) - it was there; f) now I just needed to find numbers 96 and 8 for chr and if. Then fill in placeholders and volià. \$\endgroup\$
    – bwoebi
    Commented Nov 5, 2014 at 18:47

PHP, size 54, by Steve Robbins


Not the original solution, I think.

  • 2
    \$\begingroup\$ Haha, that's lovely. I started by fishing out the echo and the while, but then couldn't be bothered to find a loop that produces 42. \$\endgroup\$ Commented Nov 5, 2014 at 18:22
  • \$\begingroup\$ There was a while in my original. \$\endgroup\$ Commented Nov 5, 2014 at 19:17

C, es1024, length 70

e='C',f;main(g){Chorkil:f=printf("40%.d",e+e-  -g);}hAx;*hotpoCkats();

The hard part ended up being to keep track of all the unneeded characters...seriously...I had to redo them about 10 times. The only one that worried me was the . but somehow I stuck it in the middle of the printf format string and it became invisible!


Python 3, size 110, by Sp3000

import sys,io
import this
u.write(" ".join(_.getvalue().split()[::9]))

This was a fun one :)


Haskell, size 34, by Petr Pudlák


Note that this program must be run on a 32-bit machine. If you want to check that this is the correct program and you have a 64-bit machine, you can use this instead:

import Data.Int

It was pretty easy to guess the "frame" of the program main=print(0x<hex digits>^0x<hex digits>::Int). All the magic was in searching for the right way to partition and order the digits. I didn't do very much smart here, just a brute-force search... though I did take care to abuse the fact that some digits were duplicated, there were probably about an equal number of digits in the base and exponent, and the last digit of the base almost certainly wasn't even. The complete search code is included below; it uses the multiset-comb package. The full search takes about 10:33 on my machine (and produces only one right answer, of course).

{-# LANGUAGE NoMonomorphismRestriction #-}
import Control.Monad
import Data.Int
import Data.List (inits, tails, group)
import Numeric
import Math.Combinatorics.Multiset

main = print (searchFor (-1121766947))

searchFor n = do
    nl <- [6,5,7,4,8,3,9,2,10,1,11]
    (l_, r_)  <- chooseSubbag nl digits
    l <- perms l_
    guard (last l /= '2')
    r <- perms r_
    guard ((fromString l :: Int32) ^ (fromString r :: Integer) == n)
    return (l, r)

chooseSubbag n = chooseSubbag' n . group
chooseSubbag' n xss = go (drop (n-1) (concat xss)) n xss where
    go _  n xss | n < 0 = []
    go _  0 xss = [([],concat xss)]
    go [] n xss = []
    go m  n (xs:xss) = do
        (kx, tx) <- zip (tails xs) (inits xs)
        (k , t ) <- go (drop (length tx) m) (n-length kx) xss
        return (kx++k, tx++t)

digits = "1223577bdfff"
fromString = fst . head . readHex
perms = permutations . fromList

Javascript, 82, by TrungDQ

b=/v/[0]+' ';b[0]+b[9]+b[6]+b[7]+'v'+b[7]+((0==0)+b)[1]+b[9]+b[4]+b[5]+b[6]+b[2];

Took forever to get the indexes right.

2 3 4 5

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.