14
\$\begingroup\$

This is the robbers' thread. The cops' thread goes here.

In the cops thread, the task was to create a program that outputs printable ASCII characters in ascending order. The robbers task is to unscramble the code the cops used to produce this output.

The cracked code doesn't have to be identical, as long as it has the same length and any revealed characters are in the correct positions. The language must also be the same (version numbers can be different). The output must of course be identical. Cops can not use comments in their code, but robbers are free to use them.

The winner of the robbers thread will be the user who has cracked the most submissions by January 7th 2016. If there's a tie, the user who has cracked submissions with the longest combined code will win.

The submission should be formatted like this:

Language, nn characters (including link to answer), Cop's username

Code:

alphaprinter

Output

abcdefghijklmnopqrstuvwxyz

Optional explanation and comments.

Leaderboard:

A crushing victory by Adnan!

Adnan: 7
Pietu1998: 3
Mitch Schwartz: 2
Quintopia: 2
Martin Büttner: 2
cat: 1
Dennis: 1
insertusernamehere: 1
isaacg: 1
jimmy23013: 1
MegaTom: 1
plannapus: 1
user81655: 1
\$\endgroup\$

24 Answers 24

7
\$\begingroup\$

Brainfuck, 48 bytes, Adnan

++++[>++++[>++++<-]<-]+++[>++++++++<-]>++[>+.<-]

Pretty straightforward, generating 64 and then 26. It might be a little red herring that

++++[>++++[>++++<-]<-]>>+

is a way to get 65, so you might try to do something like

++++[>++++[>++++<-]<-]>>+[>+++++>++<<-----]>>[<.+>-]

before noticing that it's a dead end.

\$\endgroup\$
1
  • \$\begingroup\$ Ahhh, well done :) \$\endgroup\$
    – Adnan
    Dec 27, 2015 at 7:20
6
\$\begingroup\$

Python 2, 76 characters, wnnmaw

Code, with obfuscated version below:

print "BKT]f"#__h______________________v_____________,___)_________)_______)
print __________h______________________v_____________,___)_________)_______)

This outputs BKT]f. Not the intended version, that's for sure haha.

Tested here

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Sneaky comments :) \$\endgroup\$
    – wnnmaw
    Dec 29, 2015 at 14:11
  • 1
    \$\begingroup\$ That'll teach you to post a program whose output is shorter than the length of the program in a language that has print unless you have revealed characters in exactly the places the string would have to sit. \$\endgroup\$
    – quintopia
    Dec 30, 2015 at 15:29
6
\$\begingroup\$

CJam, 12 characters, Dennis

":0[Aa#":,:^

It's in the tips...

\$\endgroup\$
1
  • \$\begingroup\$ Right, I had forgotten about the tips... \$\endgroup\$
    – Dennis
    Dec 26, 2015 at 15:46
6
\$\begingroup\$

CJam, 8 characters, Martin Büttner

Code (with blanked code):

{`:)$}_~
__:_____

Output:

%*;a|~

Try it online.

I sort of had a feeling about this from the moment I saw it. And I thought I didn't know CJam...

\$\endgroup\$
5
\$\begingroup\$

Labyrinth, 5 characters, Martin Büttner

Code:

!!!>@

Test it here

Output:

000000
\$\endgroup\$
0
4
\$\begingroup\$

JavaScript (ES6), 17 characters, Neil

As the OP posted a function, here's a solution using a function:

()=>xxx=11000+233
__=____=_________

The anonymous function can be invoked like:

(()=>xxx=11000+233)();

A more ridiculous solution I had at first:

xx=yyyy=z=11230+3
__=____=_________

When run in the console, it will print the number 11233.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ Ninja'd me. I got fx=asdf=> "11233" \$\endgroup\$ Dec 26, 2015 at 20:28
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Thought, I had to be fast on this one. :D \$\endgroup\$ Dec 26, 2015 at 20:30
  • 1
    \$\begingroup\$ Well, kudos to you on your fastest gun in the west. +1 \$\endgroup\$ Dec 26, 2015 at 20:31
  • \$\begingroup\$ -1 for no strings :P \$\endgroup\$
    – user46167
    Dec 26, 2015 at 20:35
  • 1
    \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ's version seems to be the only one that's a function that returns a string. \$\endgroup\$
    – Neil
    Dec 26, 2015 at 21:20
4
\$\begingroup\$

PHP, 28 characters, Niet the Dark Absol

I found several versions for this task:

Original version:

<?=@implode(range('a','z'));

My version:

<?=join('',range('a', 'z'));

23 character version:

<?=join('',range(a,z));

26 character version:

<?=implode('',range(a,z));

Of course, you can just add several whitespaces to get to the 28 character mark.

Tested here

\$\endgroup\$
2
  • \$\begingroup\$ Dang, you beat me :P The shortest I can do: <?=join(range(a,z)); \$\endgroup\$ Dec 26, 2015 at 20:37
  • \$\begingroup\$ You got me - maybe I should have made it more restrictive by putting one of the letters of a function name as the revealed characters... Anyway, for the record, here's the original: <?=@implode(range('a','z')); \$\endgroup\$ Dec 26, 2015 at 20:38
4
\$\begingroup\$

Jolf, 27 characters, Cᴏɴᴏʀ O'Bʀɪᴇɴ

After a few hours of trial and error, I got it haha:

on-pl'u'Wa-n"vwxyz"`--'01_2

Including obfuscated code:

on-pl'u'Wa-n"vwxyz"`--'01_2
________W___________--_____
                         |

Try it here (step run seems to be the only one working with alert)


Explanation

First thing I got stuck on was the placement of the while loop. I didn't seem to get it on the right place haha. After getting it right, the second thing I noticed was the placement of the underscore. I thought I almost got it, until I got stuck on the underscore (gg Cᴏɴᴏʀ O'Bʀɪᴇɴ).

Here is full explanation of the code:

on-pl'u'Wa-n"vwxyz"`--'01_2

o                           # assign
 n                          # n / standard variable
   pl                       # pl = "abcdefghijklmnopqrstuvwxyz"
  -  'u                     # pl - "u" = "abcdefghijklmnopqrstvwxyz"
       'W                   # a string in the middle doing nothing
          -n"vwxyz"         # n - "vwxyz"
         a                  # alert(
                   `        # is an extra semicolon
                     -'01   # "0" - 1
                    -    _2 # ("0" - 1) - negative 2

In pseudocode:

n = minus("abcdefghijklmnopqrstuvwxyz", "u");
"W";
alert(minus(n,"vwxyz"));
;
minus(minus("0", 1), negative(2));

I'm interested to see what the actual solution was :)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ holy mother of God not what I intended o______o but nice job, anyhow! I posted the actual code on my answer. \$\endgroup\$ Dec 28, 2015 at 0:50
4
\$\begingroup\$

Pyth, 6 bytes, Pietu1998

Ssy>TG

Take the last 10 letters of the alphabet, form all subsets, concatenate, sort.

\$\endgroup\$
4
\$\begingroup\$

R, 60 bytes, Fax Machine

Code:

cat(c(0:9,LETTERS[1:8],LETTERS[20:26],letters[4:23]),sep="")

Output:

0123456789ABCDEFGHTUVWXYZdefghijklmnopqrstuvw
\$\endgroup\$
4
\$\begingroup\$

Seriously, 7 characters, by quintopia

2'aNsES

Tested here.

Splits 99 bottles of beer around as and sorts the third chunk.

\$\endgroup\$
1
  • \$\begingroup\$ I used the 7th chunk, but the result is the same. Knew this one would be a cinch ;) \$\endgroup\$
    – quintopia
    Dec 28, 2015 at 13:17
4
\$\begingroup\$

Python 3, 58 bytes, Mathias Ettinger

import string;print(''.join(sorted(string.printable))[5:])

Basic use of string module.

\$\endgroup\$
2
  • \$\begingroup\$ I didn't see that you'd cracked this before me, I tried using string but didn't think of using sorted (because I forget it exists). I don't know if I should leave my crack up, since it's nowhere near the same method but it works. \$\endgroup\$
    – cat
    Dec 29, 2015 at 0:34
  • 2
    \$\begingroup\$ @cat I don't know what Stewie Griffin's opinion would be about that, but anyway I gave you +1 and think it makes sense to keep your answer up since it's not the same answer as mine. \$\endgroup\$ Dec 29, 2015 at 1:26
4
\$\begingroup\$

05AB1E, 13 characters, Adnan

Code (and blanked code):

1TD*<F3<*}bRJ
__D____<_____

Output:

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001

Explanation:

1                       Push 1
 TD*<                   Push 99
     F   }              For loop
      3<*               multiply top of stack by 3-1 (e.g. double it)
          b             convert to list of binary digits (note we have just computed 2^99)
           R            reverse it
            J           join it into a string.
                        (top of stack implicitly printed)
\$\endgroup\$
1
  • \$\begingroup\$ Woooww!! Amazing job :) \$\endgroup\$
    – Adnan
    Dec 29, 2015 at 10:27
3
\$\begingroup\$

JavaScript, 83 characters, BlockCoder1392

a=aaaaraaaa=uaaaa=aasaa=console;b=0;a.log("Hi~~~");auaaaaaaaAaaaaaaaa =aeaaaa="^~^"

A bit too many characters for such a short string.

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

JavaScript (ES6), 60 characters, insertusernamehere

Code:

e=e=>{try{a}catch(e){return[...e.toString()].sort().join``}}
e_e_______a__a____e___e________e__o___________o______o______

Output (in Chrome):

    :ERacddeeeeeeffiinnnoorrrrst

I knew this immediately because I was about to do the same thing! xD

\$\endgroup\$
4
  • \$\begingroup\$ Nice one - character by character. :D \$\endgroup\$ Dec 26, 2015 at 23:13
  • 1
    \$\begingroup\$ @insertusernamehere You could have done [...e+''] to make it a bit shorter. That threw me off at the start. ;) \$\endgroup\$
    – user81655
    Dec 26, 2015 at 23:14
  • \$\begingroup\$ What does return[...e.toString()] actually do? I only know a lil JS... \$\endgroup\$
    – cat
    Dec 27, 2015 at 5:20
  • 3
    \$\begingroup\$ @cat It just puts each letter of the error message into an array. It needs to do this because sort only works on arrays, not strings. \$\endgroup\$
    – user81655
    Dec 27, 2015 at 5:31
3
\$\begingroup\$

Pyth, 6 characters, Adnan

Code (with blanked code):

S`.n 3
S_____

Output

.0113345678888999

Try it online.

It's φ's representation, sorted. This could've been done in 5, if you remove the space.

\$\endgroup\$
1
  • \$\begingroup\$ Awww, I forgot about the backticks :p. My original code was S+.n3" \$\endgroup\$
    – Adnan
    Dec 27, 2015 at 17:52
3
\$\begingroup\$

Malbolge, 254 characters, frederick

Obfuscated version:

_____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ __

My version:

('&%: ^"!65 4Xzyx w4-Qs rpo'K mlk"' ~Dfdc ba}v< ::8[Z XnVlq }0/mO ,*MbK JH^6# 4`C|0 ?U=Sw uPsaq L4on2 Mjjh, ged)c '<$$p ]!};Y WiVxS eRQ>= ).K]l Ij"Fh gfedc b,=;z L\q%H X3E2C /ng-k N*KJI 8%6#D ~2^Ai >g<<d tUr`6 oJ"!1 /|{CU f)d>b <A_^! \};Yj yUxTS dtsr` ML

This will output:

`AB\cd`

You can try it here.

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

Befunge, 11 characters, histocrat

Code:

89'**'z...@

Output:

1223788

That was fun. This is an alternate solution I also found:

8]..@#37.z'
\$\endgroup\$
1
  • \$\begingroup\$ Oh, cool, funge-98 solutions. \$\endgroup\$
    – histocrat
    Dec 29, 2015 at 20:22
2
\$\begingroup\$

05AB1E, 7 characters Adnan

Code and blanked code:

576T*uH
___T___

Output:

22368

Explanation:

576       Push this number.
   T      Push ten.
    *     Multiply. (5760)
     u    Convert to string.
      H   Interpret as a hex number and push decimal (22368) (implicit output).

I almost positive this wasn't the original program, but thanks to Adnan for providing the one bit of information that made it possible (the u command).

\$\endgroup\$
1
  • \$\begingroup\$ I think this was the original program haha. Well done :) \$\endgroup\$
    – Adnan
    Dec 30, 2015 at 15:36
2
\$\begingroup\$

This answer is invalid and shouldn't count towards my score (not that I'm anywhere near winning anyways) because I didn't see it had already been cracked.

Python 3, 58 characters, Mathias Ettinger

Code, with original code below:

x=range(95);  print(''.join((chr(i+32) for i in x  )    ))
______________print(_______(_______________________)_____)

Clearly not the intended solution, which was:

import string;print(''.join(sorted(string.printable))[5:])

Output:

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

(Note the leading space.)

A fun one to crack: it took me a while to figure how to get the genexpr to work properly. :)

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

Pyth, 17 characters, Luke

Code (with blanked code):

S`u]G6*T`t"#X0231
___________#____1

Output:

""''''''''''''''''''''0000000000111111111122222222223333333333XXXXXXXXXX[[[[[[]]]]]]

Try it online.

This was fun. I got it to 18 bytes multiple times using # as the filter operator, but then I figured out I could just discard it from the string. If you remove the t and the # the result would probably be the shortest Pyth code for that output.

Basically:

  • "#X0231 makes the string #X0231
  • t"#X0231 removes the #: X0231
  • `t"#X0231 gets the string representation: 'X0231'
  • *T`t"#X0231 multiplies it by 10: 'X0231''X0231''X0231'
  • u]G6*T`t"#X0231 wraps it in an array 6 times
  • `u]G6*T`t"#X0231 gets the string representation: [[[[[['X0231''X0231']]]]]]
  • S`u]G6*T`t"#X0231 sorts it to get the output
\$\endgroup\$
1
  • \$\begingroup\$ Very nice! And pretty different from what I had done. \$\endgroup\$
    – Luke
    Dec 29, 2015 at 23:45
1
\$\begingroup\$

CJam, 9 characters, by username.ak

'a{_)}25*

Try it online!

How it works

'a         e# Push the character 'a'.
  {  }25*  e# Do 25 times.
   _       e# Copy the character on the stack.
    )      e# Increment the copy.
\$\endgroup\$
0
\$\begingroup\$

Perl 5, 30 characters, msh210

Obfuscated + my version:

print_________________________
print "9:;\@AFGHLMNRSTYZ_`a"  

This will output:

9:;@AFGHLMNRSTYZ_`a

Tested here

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

Python 2, 62 characters, RikerW

Obfuscated version:

______________________________________________________________
         | |   ||                  |  |  ||

My version:

print "ab_c_de___".replace("_","")#___________________________

This simply removes all the underscores and outputs abcde.

Tried it here

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.