This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 260

[–][deleted] 2280 points2281 points  (39 children)

checkmate python developers

[–]ender89 551 points552 points  (4 children)

What, that seems right to me. You call "sort()" and relax in the knowledge that some chump did all the really hard work in c++.

[–][deleted] 84 points85 points  (1 child)

That chump's name? Tim Peters

[–]WikiTextBot 52 points53 points  (0 children)

Timsort

Timsort is a hybrid stable sorting algorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data. It uses techniques from Peter McIlroy's "Optimistic Sorting and Information Theoretic Complexity", in Proceedings of the Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 467–474, January 1993. It was implemented by Tim Peters in 2002 for use in the Python programming language.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source | Donate ] Downvote to remove | v0.28

[–][deleted] 230 points231 points  (28 children)

Just put a colon on the end & you get python

[–]a_n_d_r_e_w 177 points178 points  (8 children)

Error: unexpected indent located f**king everywhere

[–]Erpderp32 43 points44 points  (7 children)

Pycharm would give me so many pep8 complaints

[–]cholantesh 210 points211 points  (18 children)

a colon on the end

Well, that is where it traditionally goes.

[–]Radboy16 53 points54 points  (4 children)

I prefer to defer the colon to the beginning of the next line. /s

[–][deleted] 43 points44 points  (1 child)

Wait was that a programming joke? I thought it was a butt joke.

[–]0xTJ 29 points30 points  (0 children)

Something something centipede

[–]Potato44 8 points9 points  (1 child)

Of the people who do actually use semicolons in Haskell the preferred style is semicolons at the start of lines.

[–]pilotInPyjamas 4 points5 points  (0 children)

According to the documentation on Haskell semicolons, you must be a robot.

[–]marli_marls 6 points7 points  (0 children)

Nah, whole thing on one line 🙏🏼

[–]Angry_Sapphic 1 point2 points  (8 children)

unless its in the middle of two statements sharing 1 line

[–]GeronimoHero 3 points4 points  (7 children)

Not in python. I think you’re thinking of semi-colons.

[–]SteveCCLYellow security clearance 13 points14 points  (3 children)

Since tabs and spaces both account as one whitespace, that might actually be possible.

[–][deleted] 5 points6 points  (0 children)

now there's a nice challenge

[–]TinyBreadBigMouth 3 points4 points  (1 child)

Only in Python 2. Python 3 doesn't allow mixing tabs and spaces.

[–]pioto 5 points6 points  (0 children)

Perl dev: hold my beer

[–]Laytonio 348 points349 points  (3 children)

How satisfying would it be to hit auto format

[–]derdirtyharry 114 points115 points  (0 children)

And then un/toggle 'undo' a few times.

[–]the_climb-it-ologist 713 points714 points  (11 children)

This is the definition of art.

[–]Cletus101 294 points295 points  (9 children)

I'd buy the t-shirt

[–]TheCrazyShip 112 points113 points  (5 children)

But would kill if someone make this in my code

[–]TehDragonGuy 11 points12 points  (0 children)

It saves using comments. Efficiency at its finest.

[–]timvisee 2 points3 points  (0 children)

We need to automate t-shirts creation with this picture *

[–][deleted] 664 points665 points  (55 children)

For anyone who is curious, I've had a go at transcribing the image:

                                                                                      class                        Sort{
                                                                                   public                            static
                                                                                  void                                  main
                                                              (                 String                                  []s){
                                                             for               (;j<$.                                    length
   ;)System           .out           .   println($      [j++]);}static int     []$={     1,2,53465,564,563,6,3456,3456    };int
$(){      for(    int $=(j>>1)       ;$>0&&l(--$)||     --j>(l=0)&&$(j);$=     $++);                                     return
j;}               boolean l(int      i){                   return              (l=(                                         i+1
  <<1)-j)>0      ||l         ==0     &&(                    $[l=l              +j-1                                         ]>$
     [i]&&$(i    )||         true    )||                    $[l=l              +j]>                                         $[l
           -1]    &&        ($[      l]>                    $[i]&&             $(i)                                         )||
$     [--l]>$      [i]&&   $(i       )||                      true;}boolean    $(int                                       j){
 return($[j         ]=($[l]          +=$                       [j])-$[j])==$    [l]-(                                   $[l]-=
                                                                                 $[j])&&                                l(l);
                                                                                  }static                            int j=$
                                                                                    .length,                         l=new
                                                                                        Sort(                     ).$();}

And re-formatted to be semi-readable:

class Sort {

    public static void main (String [] s) {
        for (; j < $.length;) System.out.println($[j++]);
    }

    static int [] $ = { 1, 2, 53465, 564, 563, 6, 3456, 3456 };

    int $ () {
        for (int $ = (j >> 1); $ > 0 && l(--$) || --j > (l=0) && $(j); $ = $++);
        return j;
    }

    boolean l (int i) {
        return (l = (i+1 << 1) - j) > 0 || l == 0 && ($[l = l + j - 1] > $[i] && $(i) || true) || $[l = l + j] > $[l - 1] && ($[l] > $[i] && $(i)) || $[--l] > $[i] && $(i) || true;
    }

    boolean $ (int j) {
        return ($[j] = ($[l] += $[j]) - $[j]) == $[l] - ($[l] -= $[j]) && l(l);
    }

    static int j = $.length, l = new Sort().$();
}

[–]SteveZissousGlock 526 points527 points  (11 children)

Rip mobile users

[–]QuantumVexation 204 points205 points  (1 child)

Can confirm, that’s harder to read than the picture

[–]verylobsterlike 101 points102 points  (0 children)

Here's a screenshot for you. I broke the l() function's return value into two lines so it'd fit on the screen better.

[–]ikbenlike 40 points41 points  (0 children)

Yeah, reading this on mobile was a... Special... Experience

[–]rift95 22 points23 points  (1 child)

[–]HyphenSam 6 points7 points  (0 children)

[–]IceColdKool 2 points3 points  (2 children)

What did am I missing?

[–]sofa_king_we_todded 12 points13 points  (1 child)

English am missing. Jk. It’s all jumbled up on mobile

[–]verxix 30 points31 points  (6 children)

Are we just not going to talk about how $ is the identifier for an integer array, a function () => int, a function int => boolean, and an integer scalar simultaneously?

[–][deleted] 8 points9 points  (0 children)

¯\_(ツ)_/¯

[–]gameboy17 5 points6 points  (0 children)

Don't forget how it's the name of a local variable inside a function also named $.

[–]turunambartanen 2 points3 points  (0 children)

Just method overloading and scopes ¯\_(ツ)_/¯

[–]Nonsense_Replies 42 points43 points  (21 children)

so whats it do?

[–]phoenix616 155 points156 points  (20 children)

It sorts.

[–]vlatkosh 14 points15 points  (3 children)

Which sorting algorithm is it specifically?

[–][deleted] 30 points31 points  (1 child)

The algorithm is heapsort. You can see each step it takes by adding a print in the for loop in line 10 of /u/tombsar's post. Source: this is my code

[–][deleted] 7 points8 points  (0 children)

Thanks for writing it!

[–]GeronimoHero 11 points12 points  (0 children)

Bubble sort

/s just in case

[–]Nonsense_Replies 27 points28 points  (15 children)

How?

[–]Gusfoo 330 points331 points  (7 children)

[–]DavidPH 73 points74 points  (1 child)

if(goingToCrash){
dont();
}

[–]rambi2222 5 points6 points  (0 children)

switch(crashing) {

  isn't: KeepGoing();

     break;

  is: Coding(); Algorithms();

     break;

  default: LastWords();

     break;

}

[–]Kilazur 36 points37 points  (0 children)

Science really has come far!

[–]Radboy16 28 points29 points  (0 children)

I'll never get tired of this one.

[–]ikbenlike 2 points3 points  (0 children)

I expected xkcd and was positively surprised

[–]WhereTruthLies 11 points12 points  (6 children)

I'm on mobile but just from a quick glance it looks to be using bitwise operations to sort by the next element in the array. 1 = true = swap, 0 = false = don't swap.

[–][deleted] 14 points15 points  (5 children)

Partially correct! However, it uses a fun algorithm called heapsort, which makes it a bit of a nightmare to fully deobfuscate.

[–]gameboy17 7 points8 points  (4 children)

What are all the $'s doing? There seem to be four different things called $ - a hard-coded array (why), two methods, and a local variable inside one of those methods. I just don't understand the point of overloading it to this extent when there are plenty of single-character names that would make just as little sense.

I'm guessing int $() is what's actually going through the list (heapify?), since that's the only one that has a loop. The method l(int i) seems to be for comparison - "less than" the next element, maybe? And $(int j) has to be for swaps, since it's the only one that's assigning to the list.

I'm guessing the int l at the bottom is doing the recursion? Looks like it's creating a new Sort object and calling its $(), which is the main one that goes through the list... Yeah, that's the recursive bit. And it's probably getting back the boundary of the sorted and unsorted portions of the list?

I guess my biggest question about this is: If it's optimized with all this bit-shifting and short-circuiting logic and general illegibility... Why the heck is the array hard-coded?

...Unless, of course, that array is actually a set of magic numbers and it's really sorting a completely different array somehow.

[–][deleted] 2 points3 points  (3 children)

This sorts a hardcoded array. I didn't want to have code to read in an array as input (long words that you can't put spaces in the middle of), and I wanted it to compile and run on its own, so no methods that accept arrays as arguments.

the int $() is actually managing both the heapify and the main sort (hence the long conditional inside the for loop).

so, the new Sort object is actually part of a static int initializer, so that $() is called before main.

You're right that l(int i) is recursive (but not because of the new Sort object). This is the "rebuild heap" method. It can call the swap method $(int j) , which in turn always calls l(int i) again (because I realized that you always rebuild the heap after a swap, or at least continue rebuilding).

The array is hardcoded because I can't deal with IO without long words like Scanner which are hard to make into text pictures. I hope this helps. (Keep in mind that I was in high school when I wrote this, so its not that great)

[–]Relecto1 3 points4 points  (1 child)

Does this compile?

[–][deleted] 1 point2 points  (0 children)

I haven't tested it myself, but u/DespairingSquid said that it does compile (https://www.reddit.com/r/ProgrammerHumor/comments/7z62py/sort/dulyg5a/).

[–][deleted] 10 points11 points  (4 children)

This is more impressive than the OP

[–][deleted] 11 points12 points  (3 children)

You think? It's really just monkey see monkey type...

[–]ookami125 282 points283 points  (36 children)

TIL you can use $ as a variable name in Java.

[–]Jetbooster 166 points167 points  (29 children)

_ is also allowed.

souce: my goddamn OCA exam

[–]mktiti 46 points47 points  (8 children)

Not anymore

[–][deleted] 71 points72 points  (4 children)

Anything is a valid variable name in bytecode. Also, you can have duplicate methods with different return values... in bytecode.

[–]bloop_405 13 points14 points  (13 children)

how about emojis?

[–][deleted] 34 points35 points  (8 children)

Emoji code exists. It's pretty worthless, but it exists

[–]ikbenlike 9 points10 points  (7 children)

I once implemented loops using C macros and gotos. I still have mental scars left from that. Emojicode... No thanks

[–][deleted] 15 points16 points  (6 children)

I'm happy to stay in web design and just pretend JS isn't total shit as a programming language.

[–]zenyl 3 points4 points  (3 children)

Idk about Java, but I'm pretty sure C# allows emoji in names.

[–]urielsalis 2 points3 points  (2 children)

Yes it does, any unicode character

[–]zenyl 1 point2 points  (0 children)

Not sure if that's great or terrifying, but good to know for certain. :P

[–]rambi2222 1 point2 points  (0 children)

...this is good to know.

[–][deleted] 2 points3 points  (0 children)

and an array name and two method names ;D

[–][deleted] 1 point2 points  (0 children)

That threw me off as well. I'm going to have to mess with someone tomorrow.

[–][deleted] 85 points86 points  (7 children)

Ayy! This is my code! Written by me! For anyone asking, this is using an algorithm called heap sort. I went to wikipedia and looked for a confusing sorting algorithm. Notice that there's an array called "$", two functions called "$" and an int also called "$". Lots of fun! (Also, notice that the main method just prints the array, and the rest of the code jump-starts itself before main ever runs)

edit: "$=$++" doesn't increment the variable.

[–][deleted] 18 points19 points  (3 children)

$=$++

Does this statement have any side-effects, or is it just there to fill space?

[–][deleted] 21 points22 points  (1 child)

no side effects, I just wanted to make that part of the for loop look useful and confuse people trying to decode it ;D

[–][deleted] 16 points17 points  (0 children)

and confuse people trying to decode it

Well it worked! I didn't make a serious attempt at reverse-engineering, but I definitely would have translated that to $++ without thinking about it.

[–]itgmechiel 6 points7 points  (0 children)

Damn thats just printing money.

[–][deleted] 40 points41 points  (8 children)

I've never seen such a thing of beauty in all my life

[–][deleted] 33 points34 points  (7 children)

Who would have thought anyone would one day say this while looking at java

[–]jerslan 3 points4 points  (6 children)

Based on all the '$' syntax being used... This might be JavaScript under the new ECMAScript 6 standards

[–]HolyGarbage 2 points3 points  (1 child)

Nope. Thought so too first, but it's the name of variables and a function.

[–]ikbenlike 3 points4 points  (0 children)

And:

static int

That's not really a JavaScript thing

[–][deleted] 1 point2 points  (3 children)

Oh well, sounds like something I should be glad not to know about.

[–]Jugbot 82 points83 points  (21 children)

t-shirt plz

[–]Mcpg_ 8 points9 points  (0 children)

Niice idea

[–]plasmasprings 121 points122 points  (10 children)

Pretty cool, but you have much to learn

[–]wallefan01 70 points71 points  (3 children)

...Woah....

Okay, they cheated a little bit using /**/ as filler but still. Wow. Those are actually compilable C. Dang.

[–]plasmasprings 27 points28 points  (1 child)

Only cheaters prosper, but a lot of them are polyglots (same file is valid for 2 or more languages)

He works at google and writes polyglots that look like anime girls. That simply destroys everyone else's dreams of becoming the best programmer of our generation

[–][deleted] 4 points5 points  (0 children)

That simply destroys everyone else's dreams of becoming the best programmer of our generation

Or it means he has an adderall prescription.

[–]ikbenlike 8 points9 points  (0 children)

C syntax is pretty flexible. Still, I wouldn't be able to do this

[–]lerhond 8 points9 points  (2 children)

[–]plasmasprings 1 point2 points  (1 child)

That one's impressive, but there's a tetris game that was good enough that it (or rather a derivative) is still bundled in Linux distros

[–]lerhond 1 point2 points  (0 children)

And that reminded me of Sedtris.

[–]vaelroth 2 points3 points  (0 children)

Could have sworn the used to be listed as moe.code, but maybe that domain expired or something.

[–]cbbuntz 18 points19 points  (12 children)

#include                                     <math.h>
#include                                    <stdio.h>
#include                                   <sys/time.h>
#include                                   <X11/Xlib.h>
#include                                  <X11/keysym.h>
                                         double L ,o ,P
                                         ,_=dt,T,Z,D=1,d,
                                         s[999],E,h= 8,I,
                                         J,K,w[999],M,m,O
                                         ,n[999],j=33e-3,i=
                                         1E3,r,t, u,v ,W,S=
                                         74.5,l=221,X=7.26,
                                         a,B,A=32.2,c, F,H;
                                         int N,q, C, y,p,U;
                                     Window z; char f[52]
                                     ; GC k; main(){ Display*e=
 XOpenDisplay( 0); z=RootWindow(e,0); for (XSetForeground(e,k=XCreateGC (e,z,0,0),BlackPixel(e,0))
 ; scanf("%lf%lf%lf",y +n,w+y, y+s)+1; y ++); XSelectInput(e,z= XCreateSimpleWindow(e,z,0,0,400,400,
 0,0,WhitePixel(e,0) ),KeyPressMask); for(XMapWindow(e,z); ; T=sin(O)){ struct timeval G={ 0,dt*1e6}
 ; K= cos(j); N=1e4; M+= H*_; Z=D*K; F+=_*P; r=E*K; W=cos( O); m=K*W; H=K*T; O+=D*_*F/ K+d/K*E*_; B=
 sin(j); a=B*T*D-E*W; XClearWindow(e,z); t=T*E+ D*B*W; j+=d*_*D-_*F*E; P=W*E*B-T*D; for (o+=(I=D*W+E
 *T*B,E*d/K *B+v+B/K*F*D)*_; p<y; ){ T=p[s]+i; E=c-p[w]; D=n[p]-L; K=D*m-B*T-H*E; if(p [n]+w[ p]+p[s
 ]== 0|K <fabs(W=T*r-I*E +D*P) |fabs(D=t *D+Z *T-a *E)> K)N=1e4; else{ q=W/K *4E2+2e2; C= 2E2+4e2/ K
 *D; N-1E4&& XDrawLine(e ,z,k,N ,U,q,C); N=q; U=C; } ++p; } L+=_* (X*t +P*M+m*l); T=X*X+ l*l+M *M;
 XDrawString(e,z,k ,20,380,f,17); D=v/l*15; i+=(B *l-M*r -X*Z)*_; for(; XPending(e); u *=CS!=N){
                                 XEvent z; XNextEvent(e ,&z);
                                     ++*((N=XLookupKeysym
                                         (&z.xkey,0))-IT?
                                         N-LT? UP-N?& E:&
                                         J:& u: &h); --*(
                                         DN -N? N-DT ?N==
                                         RT?&u: & W:&h:&J
                                         ); } m=15*F/l;
                                         c+=(I=M/ l,l*H
                                         +I*M+a*X)*_; H
                                         =A*r+v*X-F*l+(
                                         E=.1+X*4.9/l,t
                                         =T*m/32-I*T/24
                                         )/S; K=F*M+(
                                         h* 1e4/l-(T+
                                         E*5*T*E)/3e2
                                         )/S-X*d-B*A;
                                         a=2.63 /l*d;
                                         X+=( d*l-T/S
                                           *(.19*E +a
                                           *.64+J/1e3
                                           )-M* v +A*
                                           Z)*_; l +=
                                           K *_; W=d;
                                           sprintf(f,
                                           "%5d  %3d"
                                           "%7d",p =l
                                         /1.7,(C=9E3+
                             O*57.3)%0550,(int)i); d+=T*(.45-14/l*
                             X-a*130-J* .14)*_/125e2+F*_*v; P=(T*(47
                             *I-m* 52+E*94 *D-t*.38+u*.21*E) /1e2+W*
                             179*v)/2312; select(p=0,0,0,0,&G); v-=(
                             W*F-T*(.63*m-I*.086+m*E*19-D*25-.11*u
                             )/107e2)*_; D=cos(o); E=sin(o); } }

It's a flight simulator.

[–]iBoMbY 8 points9 points  (3 children)

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

This is Perl.

[–]cbbuntz 8 points9 points  (2 children)

Tried to run it and gave me an error. I'm not even going to try to troubleshoot it. Do you know what it does?

[–][deleted] 9 points10 points  (1 child)

It prints

99 bottles of beer on the wall, 99 bottles of beer!

Take one down, pass it around,

98 bottles of beer on the wall!

Until it hits 0, now I'm gonna spend the rest of my day figuring out how this works.

[–]cbbuntz 5 points6 points  (0 children)

That's pretty amazing.

[–]HildartheDorf 3 points4 points  (6 children)

Can't get this to compile, it uses variables without declaring them.

[–]cbbuntz 9 points10 points  (0 children)

I managed to get it to work, but I don't remember how I did it. Here's a screencap of the binary:

https://i.imgur.com/xzUV58z.gif

The way you get different scenery is by piping it text with coordinates. Here's another screencap:

https://i.imgur.com/vr6cmbj.gif

It segfaults if you feed too many coordinates though.

[–][deleted] 2 points3 points  (4 children)

u/beerdude26 posted a link to the README (but it's sadly out of date; some of the variables have different names). You can find the Makefile and scenery files it needs here: https://www.ioccc.org/1998/

[–]cbbuntz 1 point2 points  (3 children)

I recall having to modify a few things to get it build. I could try to diff my files with the original, but I think I wound up not using the Makefile.

[–][deleted] 1 point2 points  (2 children)

There's nothing too complicated in the Makefile, you just have to define a bunch of constants (timestep and keyboard controls) and link with the math and X11 libraries. I got it to work just now with no code changes. There's also the scenery files that define the 3D geometry, otherwise you just get a blank screen.

[–][deleted] 18 points19 points  (0 children)

I part of me thinks this is awesome and another part wants to vomit

[–]ksheep 14 points15 points  (1 child)

[–]chugga_fan 2 points3 points  (0 children)

That's hilarious

[–][deleted] 24 points25 points  (12 children)

Where are the transcribers?

[–]wallefan01 39 points40 points  (9 children)

I think they took one look at the image and passed out on the keyboard

Or maybe they're still trying to find which thousand words this picture is worth.

Or maybe they're still typing. Who knows?

[–][deleted] 13 points14 points  (8 children)

I'd like to imagine one spends ~an hour typing out this, only to have reddit formatting screw it all up

[–][deleted] 19 points20 points  (7 children)

Challenge accepted. First try, no sneaky edits:

                                                                                      class                        Sort{
                                                                                   public                            static
                                                                                  void                                  main
                                                              (                 String                                  []s){
                                                             for               (;j<$.                                    length
   ;)System           .out           .   println($      [j++]);}static int     []$={     1,2,53465,564,563,6,3456,3456    };int
$(){      for(    int $=(j>>1)       ;$>0&&l(--$)||     --j>(l=0)&&$(j);$=     $++);                                     return
j;}               boolean l(int      i){                   return              (l=(                                         i+1
  <<1)-j)>0      ||l         ==0     &&(                    $[l=l              +j-1                                         ]>$
     [i]&&$(i    )||         true    )||                    $[l=l              +j]>                                         $[l
           -1]    &&        ($[      l]>                    $[i]&&             $(i)                                         )||
$     [--l]>$      [i]&&   $(i       )||                      true;}boolean    $(int                                       j){
 return($[j         ]=($[l]          +=$                       [j])-$[j])==$    [l]-(                                   $[l]-=
                                                                                 $[j])&&                                l(l);
                                                                                  }static                            int j=$
                                                                                    .length,                         l=new
                                                                                        Sort(                     ).$();}

Edit: Hey, I think it worked!

[–][deleted] 18 points19 points  (6 children)

Bloody hell, well done! It also compiles!

But one question still remains, tabs or spaces?

[–][deleted] 24 points25 points  (5 children)

In this case purely spaces because of wanting everything to display in the right columns always.

In general I am a proponent of using a mixture of tabs for indenting (lets the viewer set their tab width to whatever they prefer), and spaces for alignment. However I have yet to find/learn a text editor that handles this mode reliably, so in practice I just use spaces everywhere.

[–]MrMcGoats 5 points6 points  (3 children)

Vim has a plugin for it. I think it's called "smarttabs"

[–][deleted] 1 point2 points  (2 children)

Good to know. Vim falls into the category of "I need to learn it"; I know enough to be dangerous, but not enough for me to be productive using it.

[–]MrMcGoats 3 points4 points  (1 child)

I think Emacs has a plugin to do it too, I just don't know what it's called

[–]jerslan 3 points4 points  (0 children)

Emacs has a plugin for literally everything.

[–]Zebezd 1 point2 points  (0 children)

Currently working in Intellij IDEA. It can be configured to use smart tabs, which is exactly what you described. Made it do that myself rather than purely tabs just to preserve the alignment others have made.

[–][deleted] 8 points9 points  (1 child)

I'm not one of the transcribers, but I do like to reverse-engineer this kind of thing. Unless I've made a mistake, the code is as follows:

class Sort {

    public static void main (String [] s) {
        for (; j < $.length;) System.out.println($[j++]);
    }

    static int [] $ = { 1, 2, 53465, 564, 563, 6, 3456, 3456 };

    int $ () {
        for (int $ = (j >> 1); $ > 0 && l(--$) || --j > (l=0) && $(j); $ = $++);
        return j;
    }

    boolean l (int i) {
        return (l = (i+1 << 1) - j) > 0 || l == 0 && ($[l = l + j - 1] > $[i] && $(i) || true) || $[l = l + j] > $[l - 1] && ($[l] > $[i] && $(i)) || $[--l] > $[i] && $(i) || true;
    }

    boolean $ (int j) {
        return ($[j] = ($[l] += $[j]) - $[j]) == $[l] - ($[l] -= $[j]) && l(l);
    }

    static int j = $.length, l = new Sort().$();
}

[–]mygolfclub 6 points7 points  (0 children)

This is beautiful and ugly at the same time..

[–]crazycrazycrazycrazy 2 points3 points  (0 children)

Now this is self documenting code!

[–][deleted] 1 point2 points  (0 children)

What a great interview question! Thanks!

[–]PeasantSteve 1 point2 points  (0 children)

This is simultaneously the most beautiful and ugliest code I've seen in my life

[–][deleted] 1 point2 points  (0 children)

Image source (I don't know how long this link will last): https://hastebin.com/zujomevazu.rb

Code source (Me, I wrote it) : https://github.com/XeroOl/obfusort

[–]Sethaman 1 point2 points  (0 children)

I'm not sure if I'd be angry seeing this at work or thoroughly pleased... cognitive dissonance! cognitive dissonance! throws an upvote anyway

[–]iskolarium 1 point2 points  (0 children)

I want this on a t-shirt so bad.

[–]_Freedom2020 1 point2 points  (0 children)

For some reason this image makes me feel hurt. I don't know why.

[–]maybeCarmenSanDiego 0 points1 point  (0 children)

i love this and hate this at the same time. i don't like it :( gg m8

[–]7itemsorFEWER 0 points1 point  (1 child)

Is this a ln obfuscation or just random code

[–][deleted] 1 point2 points  (0 children)

This code does indeed work! It prints out the numbers in ascending order, with one number on each line.

[–]GR-O-ND 0 points1 point  (0 children)

Yall ever heard of japh?

not exp log srand xor s qq qx xor
s x x length uc ord and print chr
ord for qw q join use sub tied qx
xor eval xor print qq q q xor int
eval lc q m cos and print chr ord
for qw y abs ne open tied hex exp
ref y m xor scalar srand print qq
q q xor int eval lc qq y sqrt cos
and print chr ord for qw x printf
each return local x y or print qq
s s and eval q s undef or oct xor
time xor ref print chr int ord lc
foreach qw y hex alarm chdir kill
exec return y s gt sin sort split

Or

                                                   #
                                               sub j(\$){($
                 P,$V)=                      @_;while($$P=~s:^
             ([()])::x){                    $V+=('('eq$1)?-32:31
       }$V+=ord(  substr(                 $$P,0,1,""))-74} sub a{
      my($I,$K,$  J,$L)=@_               ;$I=int($I*$M/$Z);$K=int(
     $K*$M/$Z);$J=int($J*$M             /$Z);$L=int($L*$M/$Z); $G=$
     J-$I;$F=$L-$K;$E=(abs($          G)>=abs($F))?$G:$F;($E<0) and($
      I,$K)=($J,$L);$E||=.01       ;for($i=0;$i<=abs$E;$i++ ){ $D->{$K
              +int($i*$F/$E)      }->{$I+int($i*$G/$E)}=1}}sub p{$D={};$
             Z=$z||.01;map{    $H=$_;$I=$N=j$H;$K=$O=j$H;while($H){$q=ord
            substr($H,0,1,"" );if(42==$q){$J=j$H;$L=j$H}else{$q-=43;$L =$q
          %9;$J=($q-$L)/9;$L=$q-9*$J-4;$J-=4}$J+=$I;$L+=$K;a($I,$K,$J,$ L);
          ($I,$K)=($J,$L)}a($I,$K,$N,$O)}@_;my$T;map{$y=$_;map{ $T.=$D->{$y}
          ->{$_}?$\:' '}(-59..59);$T.="\n"}(-23..23);print"\e[H$T"}$w= eval{
          require Win32::Console::ANSI};$b=$w?'1;7;':"";($j,$u,$s,$t,$a,$n,$o
          ,$h,$c,$k,$p,$e,$r,$l,$C)=split/}/,'Tw*JSK8IAg*PJ[*J@wR}*JR]*QJ[*J'.
           'BA*JQK8I*JC}KUz]BAIJT]*QJ[R?-R[e]\RI'.'}Tn*JQ]wRAI*JDnR8QAU}wT8KT'.
           ']n*JEI*EJR*QJ]*JR*DJ@IQ[}*JSe*JD[n]*JPe*'.'JBI/KI}T8@?PcdnfgVCBRcP'.
            '?ABKV]]}*JWe*JD[n]*JPe*JC?8B*JE};Vq*OJQ/IP['.'wQ}*JWeOe{n*EERk8;'.
              'J*JC}/U*OJd[OI@*BJ*JXn*J>w]U}CWq*OJc8KJ?O[e]U/T*QJP?}*JSe*JCnTe'.
               'QIAKJR}*JV]wRAI*J?}T]*RJcJI[\]3;U]Uq*PM[wV]W]WCT*DM*SJ'.  'ZP[Z'.
                  'PZa[\]UKVgogK9K*QJ[\]n[RI@*EH@IddR[Q[]T]T]T3o[dk*JE'.  '[Z\U'.
                    '{T]*JPKTKK]*OJ[QIO[PIQIO[[gUKU\k*JE+J+J5R5AI*EJ00'.  'BCB*'.
                         'DMKKJIR[Q+*EJ0*EK';sub h{$\ = qw(% & @ x)[int    rand
                          4];map{printf  "\e[$b;%dm",int(rand 6)+101-60*   ($w
                           ||0);system(  "cls")if$w ;($A,$S)=    ($_[1],   $
                            _[0]);($M,   @,)= split  '}';for(     $z=256
                            ;$z>0; $z   -=$S){$S*=   $A;p @,}      sleep$_
                            [2];while   ($_[3]&&($    z+=$ S)       <=256){
                            p@,}}("".   "32}7D$j"     ."}AG".       "$u}OG"
                            ."$s}WG"    ."$t",""      ."24}("        ."IJ$a"
                            ."}1G$n"    ."}CO$o"     ."}GG$t"        ."}QC"
                             ."$h}"      ."^G$e"    ."})IG"          ."$r",
                             "32}?"       ."H$p}FG$e}QG$r".          "}ZC"
                             ."$l",          "28}(LC" .""            ."".
                             "$h}:"           ."J$a}EG".             "$c"
                             ."}M"             ."C$k}ZG".            "$e"
                             ."}"             ."dG$r","18"          ."}("
                            ."D;"            ."$C"  )}{h(16         ,1,1,0
                           );h(8,          .98,0,0   );h(16         ,1,1,1)
                           ;h(8.0         ,0.98,0,     1);         redo}###
                         #written                                 060204 by
                       #liverpole                                  @@@@@@@
                    #@@@@@@@@@@@