Printing ascending ASCII, Robbers

13

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

Stewie Griffin

Posted 2015-12-26T11:53:41.933

Reputation: 43 471

Answers

7

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

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965

1Sneaky comments :) – wnnmaw – 2015-12-29T14:11:36.953

1That'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. – quintopia – 2015-12-30T15:29:24.403

7

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.

Mitch Schwartz

Posted 2015-12-26T11:53:41.933

Reputation: 4 899

Ahhh, well done :) – Adnan – 2015-12-27T07:20:09.260

6

CJam, 12 characters, Dennis

":0[Aa#":,:^

It's in the tips...

jimmy23013

Posted 2015-12-26T11:53:41.933

Reputation: 34 042

Right, I had forgotten about the tips... – Dennis – 2015-12-26T15:46:15.970

6

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

PurkkaKoodari

Posted 2015-12-26T11:53:41.933

Reputation: 16 699

5

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965

4

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.

insertusernamehere

Posted 2015-12-26T11:53:41.933

Reputation: 4 551

2Ninja'd me. I got fx=asdf=> "11233" – Conor O'Brien – 2015-12-26T20:28:29.497

@CᴏɴᴏʀO'Bʀɪᴇɴ Thought, I had to be fast on this one. :D – insertusernamehere – 2015-12-26T20:30:54.567

1Well, kudos to you on your fastest gun in the west. +1 – Conor O'Brien – 2015-12-26T20:31:20.387

-1 for no strings :P – ev3commander – 2015-12-26T20:35:03.713

@BlockCoder1392 Hehe. I refactored my solutions. At first I had xx=yyyy=z="11233" which will literally return "11233" which is not the same as 11233. That's why I took the addition approach. :) – insertusernamehere – 2015-12-26T20:37:32.273

However, +1 for xx=yyyy=z=11230+3 – ev3commander – 2015-12-26T20:39:01.117

1@CᴏɴᴏʀO'Bʀɪᴇɴ's version seems to be the only one that's a function that returns a string. – Neil – 2015-12-26T21:20:11.100

@Neil I can easily adopt that to be a real string, If you read the comment to BlockCoder you can see, why I changed it. Is it really necessary on PPCG for JavaScript to return an explicit string? If so, I'm happy to change that. – insertusernamehere – 2015-12-26T21:22:57.043

If I didn't think it had to return a string I wouldn't have made my function return a string. – Neil – 2015-12-26T23:25:41.140

4

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

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965

Dang, you beat me :P The shortest I can do: <?=join(range(a,z)); – LegionMammal978 – 2015-12-26T20:37:36.453

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')); – Niet the Dark Absol – 2015-12-26T20:38:35.693

4

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

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965

1holy mother of God not what I intended o______o but nice job, anyhow! I posted the actual code on my answer. – Conor O'Brien – 2015-12-28T00:50:05.573

4

Pyth, 6 bytes, Pietu1998

Ssy>TG

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

isaacg

Posted 2015-12-26T11:53:41.933

Reputation: 39 268

4

R, 60 bytes, Fax Machine

Code:

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

Output:

0123456789ABCDEFGHTUVWXYZdefghijklmnopqrstuvw

plannapus

Posted 2015-12-26T11:53:41.933

Reputation: 8 610

4

Seriously, 7 characters, by quintopia

2'aNsES

Tested here.

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

Martin Ender

Posted 2015-12-26T11:53:41.933

Reputation: 184 808

I used the 7th chunk, but the result is the same. Knew this one would be a cinch ;) – quintopia – 2015-12-28T13:17:38.570

4

Python 3, 58 bytes, Mathias Ettinger

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

Basic use of string module.

Mitch Schwartz

Posted 2015-12-26T11:53:41.933

Reputation: 4 899

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. – cat – 2015-12-29T00:34:54.797

2@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. – Mitch Schwartz – 2015-12-29T01:26:09.230

4

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)

quintopia

Posted 2015-12-26T11:53:41.933

Reputation: 3 899

Woooww!! Amazing job :) – Adnan – 2015-12-29T10:27:51.910

3

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.

Martin Ender

Posted 2015-12-26T11:53:41.933

Reputation: 184 808

3

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

user81655

Posted 2015-12-26T11:53:41.933

Reputation: 10 181

Nice one - character by character. :D – insertusernamehere – 2015-12-26T23:13:38.823

1@insertusernamehere You could have done [...e+''] to make it a bit shorter. That threw me off at the start. ;) – user81655 – 2015-12-26T23:14:46.433

What does return[...e.toString()] actually do? I only know a lil JS... – cat – 2015-12-27T05:20:38.053

3@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. – user81655 – 2015-12-27T05:31:00.270

3

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.

PurkkaKoodari

Posted 2015-12-26T11:53:41.933

Reputation: 16 699

Awww, I forgot about the backticks :p. My original code was S+.n3" – Adnan – 2015-12-27T17:52:41.237

3

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.

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965

2

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

cat

Posted 2015-12-26T11:53:41.933

Reputation: 4 989

2

Befunge, 11 characters, histocrat

Code:

89'**'z...@

Output:

1223788

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

8]..@#37.z'

MegaTom

Posted 2015-12-26T11:53:41.933

Reputation: 3 787

Oh, cool, funge-98 solutions. – histocrat – 2015-12-29T20:22:26.457

2

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

quintopia

Posted 2015-12-26T11:53:41.933

Reputation: 3 899

I think this was the original program haha. Well done :) – Adnan – 2015-12-30T15:36:46.647

1

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

PurkkaKoodari

Posted 2015-12-26T11:53:41.933

Reputation: 16 699

Very nice! And pretty different from what I had done. – Luke – 2015-12-29T23:45:01.400

1

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.

Dennis

Posted 2015-12-26T11:53:41.933

Reputation: 196 637

0

Perl 5, 30 characters, msh210

Obfuscated + my version:

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

This will output:

9:;@AFGHLMNRSTYZ_`a

Tested here

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965

0

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

Adnan

Posted 2015-12-26T11:53:41.933

Reputation: 41 965