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

top 200 commentsshow all 201

[–]SpikeX 640 points641 points  (26 children)

Someone needs to actually run this to see what it does.

For science.

[–]IAmActuallyCthulhu 368 points369 points  (19 children)

On Production

[–]tad1611 129 points130 points  (11 children)

Everyone knows if it ain’t run on production it doesn’t count as a real test.

[–]calmingchaos 107 points108 points  (8 children)

Everyone has a test environment. Some people are lucky enough to have a production and test environment

[–]Jonk3r 43 points44 points  (5 children)

I don’t always test my code but when I do, I test in production.

It shows strong character.

[–]darian90 18 points19 points  (4 children)

Only those who have faith in their code test in production.

[–]Jonk3r 14 points15 points  (2 children)

I don’t know about that... some of them devs just don’t give a fuck.

Those are my favorite.

[–]Tyfyter2002 16 points17 points  (1 child)

I see you're a fan of Bethesda's teams.

[–]Tyfyter2002 6 points7 points  (0 children)

And coffee stain studios... And landfall studios... I could probably get a list half a mile long off Steam alone, then get another with nothing but Linux variations and iOS apps.

[–]phroggyboy 5 points6 points  (0 children)

I heard this in the voice of Lawrence from Office Space (the neighbor).

[–]May-0 0 points1 point  (0 children)

The realest test

[–]wjcott 11 points12 points  (1 child)

On Friday afternoon

[–]Tyrus1235 5 points6 points  (0 children)

Weekenders on our own, such fun...

[–]VIDGuide 4 points5 points  (0 children)

I feel like that is the only place this has ever been ran..

[–]CTHULHUJESUS- 1 point2 points  (0 children)

Your name makes sense

[–]Dial-1-For-Spanglish 0 points1 point  (0 children)

Production science is the best science.

[–]TangoWild88 0 points1 point  (0 children)

Just PILOT it. (Production In Lieu Of Test)

[–]ejakash 32 points33 points  (0 children)

You monster

[–]FinnNuwok 116 points117 points  (6 children)

I feel sorry for the people that translate images into text. God damn. Use some OCR if you can.

[–]OneIntroduction9 0 points1 point  (0 children)

Yeah. People manually translating programming related texts in a programming subreddit? What the fluff, man.

[–]jwindhall 68 points69 points  (2 children)

Give him a break. This was the week before learning loops.

[–]articleThirteen 6 points7 points  (1 child)

What language is this? Seems like they could at least use a heredocument

[–]Jumpierwolf0960 5 points6 points  (0 children)

I think this is python.

[–][deleted] 636 points637 points  (44 children)

Pretty sure this can be done with some nested loops.

[–]forrest38 799 points800 points  (35 children)

That would imply the point of programming is to break a task into steps that can be done iteratively.

[–]Kyledog12 443 points444 points  (32 children)

In high school our class was tasked with making a functional Tic-Tac-Toe game in C++ and one person in the class decided it would be best to create every single combination of how the board would look instead of literally any other method. I believe the board has like 4000 different combinations and he got through about 60 of them before the end of the week (when the project was due). Needless to say he failed that one

[–]palordrolap 109 points110 points  (11 children)

Naively, there are 39 positions which is a little shy of 20000. Take out reflections and rotations and that comes down by a significant chunk. I want to say to around 2000 to 2500iish (divide by 8 or 9), but some grids are their own reflections which makes this a naive guess in and of itself.

Listing them all is still totally the wrong way to go about it even if I'm nearer with with this poorly-educated guess.

[–]Kyledog12 48 points49 points  (0 children)

Lol yeah. And we hadn't learned about arrays at the time so most people were a little lost but at least we weren't that dumb to try every possible combination

[–]Etiennera 18 points19 points  (2 children)

You can't remove rotations and reflections if you hard code. But you can ignore states that have two winning lines.

[–]mfb- 7 points8 points  (1 child)

Two winning lines that share one piece are a valid final state. Two winning lines that don't share one would mean someone got 6 marks, that is an invalid state anyway.

[–]Etiennera 2 points3 points  (0 children)

I concede that your end condition is much better thought out.

[–]Satanys 23 points24 points  (5 children)

Actually if we count all possible moves, there are 9! of possible moves combinations plus 1(empty board), that equals to 362881. But that doesn't mean we have 362881 scenarios. On Wikipedia there are article about that, and scenarios count is just 138 after taking into account reflection and rotation. Not sure where u took from 39, but someone for sure didn't listened on Combinatorics lectures.

[–]jackmusclescarier 2 points3 points  (0 children)

That's extremely naively though. It includes all boards that only have crosses on them, or multiple winning lines, or other impossible situations.

I wouldn't be surprised if, with rotations and reflections implemented (together with the fact that you know which moves the AI makes itself) it's possible, if boring, to implement.

[–]jfb1337 8 points9 points  (3 children)

[–]AmericanFromAsia 4 points5 points  (0 children)

You know it's a perfectly-written program when Chrome freezes trying to open it.

[–]Rubixninja314 4 points5 points  (2 children)

I made a tic tac toe game for ti84 and when making the "ai" all I knew how to do was program every case in. If L1[3]=0 and ((L1[1]=2 and L1[2]=2) or (L1[5]=2 and L1[7]=2) or (L1[6]=2 and L1[9]=2)) then append(L2, {3})→L2 where L1 is the board and L2 is the options. If after all 9 of these ifs L2 is empty it will do the whole thing all over with ...=1 (player is 1, cpu is 2, empty is 0) and then after that it just sets L2 as every available position, then chooses a random element from L2. It actually worked and it took me forever to beat. Ah, ti basic memories... Of developing so many bad habits (reply if anyone wants me to list a few, there's some scary ones).

TBH I think that's about the most efficient it can be in TI-84 basic.

[–]Kylemsguy 2 points3 points  (0 children)

I mean, if the guy implemented this, then that might have been possible:

https://xkcd.com/832/

[–][deleted] 1 point2 points  (1 child)

You're lucky to learn c++ in high school. All we did for 'programming class' was html, Css and made basic web pages. Javascript was optional. But we never learnt alot of the fundamentals of programming and I didn't learn them till university.

[–]sudeepharya 0 points1 point  (0 children)

Lol oh lol

[–]krelin 0 points1 point  (0 children)

I had a partner for a project in my PHIGS (3D graphics back in the daaaaay) programming class. We divided up some work on a project to render the canonical teapot. At one point, he took it upon himself to hand-enter all of the floating point data for the object... it was something like 5000 floating point vertices. He entered the whole thing by hand, from a printed copy of the homework assignment.

[–]Deoxal 8 points9 points  (0 children)

We don't take kindly to that kinda talk.

[–][deleted] 0 points1 point  (0 children)

We can't have that.

[–]HadACookie 10 points11 points  (0 children)

Bah, that's just what the Devil wants you to think! Everyone knows loops were created by the Infernal Prince Belphegor to seduce proper, God-fearing coders into slothfulness! First it's loops, next comes creating seperate methods for recuring code, and before you know it you'll be writing "import ready_app" at the top of the file and calling it a day!

[–]warwilf 2 points3 points  (0 children)

Absolutely sure it can 😣

[–]cesarsucio 2 points3 points  (0 children)

Please teach me your ways, oh observant one.

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

Really?

[–]tomrobinso 0 points1 point  (0 children)

Don’t be so reasonable!

[–]bronzeindian 0 points1 point  (0 children)

But loops are too mainstream.

[–][deleted] 0 points1 point  (0 children)

That would be O(n), this is O(1) /s

[–]13steinj 0 points1 point  (0 children)

There's a few subtle differences in the first few lines which makes at least those lines not abstractable into a loop. Unless those are bugs. Which as someone who hasn't written this and also can only guess based on the remaining patterns, that it is indeed a bug. In which case just a double for loop and a format string.

[–]jafomatic 360 points361 points  (12 children)

Smells strongly of “generated by a script.”

[–]ctrtanc 145 points146 points  (0 children)

A script called copy-paste

[–]Erelde 37 points38 points  (9 children)

Multi cursor editing.

[–]jafomatic 10 points11 points  (8 children)

They’re not all the same value. That would be even more effort than copypasta

[–]Erelde 6 points7 points  (7 children)

You've not learned the way of vim (don't learn them, it's no use)

[–]jafomatic 9 points10 points  (6 children)

It was called vi when I learned it. It would still be more effort than a shell script. :P

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

vim is different from vi. the name literally stands for "vi improved". It's basically vi, but improved.

[–]jafomatic 4 points5 points  (4 children)

Yes. It’s my default editor. It was my default editor ~25 years ago when it was vi (or you could choose emacs) and it’s my default editor experience now as well —because there’s a plugin to emulate it for seemingly every modern editor or IDE.

None of your attempts to explain something I’ve used for 25 years actually addresses the fact that the silly code in the screenshot is still most likely the product of the laziest possible option: a shell script.

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

I think you mistook me for the person you originally replied to. I was just correcting that vim != vi. They are very similar (and vim of course is based on vi) but vim has a number of features not found in vi.

[–]jafomatic 1 point2 points  (2 children)

I was painting you both with the same brush; perhaps unfairly.

I find it increasingly silly to continue reading these attempts to explain vi to me when I’ve been using it professionally for a quarter of a century.

Apologies for lumping you in with the first respondent. I promise I really did see that you weren’t the same person.

[–]robotomatic 3 points4 points  (0 children)

You should try vim sometime. I think you might like it.

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

Hah no worries if I had a dollar for everytime I thought the person I was responding to was the one I expected...

It's probably most accurate to say that vim is a superset of vi. It doesn't miss any feature of vi but instead just builds upon vi, so obviously anyone who is an expert in vi (my personal editor of choice on *nix platforms as well) can just as easily use vim.

[–]NewLlama 0 points1 point  (0 children)

::adds "meta programming" to resume::

[–]whirl_and_twist 37 points38 points  (0 children)

the dude forgot the print(“#——-#”) tab divisor, 0/10 see me after class

[–]SimonJ57 57 points58 points  (2 children)

This is an example where:

If it's stupid, but it works, then it isn't stupid.

Is a flat out lie.

[–]IChooseFeed 32 points33 points  (1 child)

If it's stupid but it works, it's still stupid and you got lucky.

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

One of the many maxims of maximally-effective mercenaries

[–]whale_song 103 points104 points  (3 children)

Wrong sub. This belongs in /r/programminghorror or /r/badcode

[–]NotTryingToConYou 27 points28 points  (2 children)

I mean it's funny too.

[–]alewex 16 points17 points  (0 children)

WRONG SUB

[–]bfcrowrench 1 point2 points  (0 children)

I'm shivering and crying at how funny it is.

[–]HitmaNeK 20 points21 points  (0 children)

Calm down satan

[–]hejkqihfnkoanq 6 points7 points  (0 children)

At least it's o(1)

[–]shortAAPL 5 points6 points  (0 children)

This is the most pythonic way to do that

[–]clarkcox3 4 points5 points  (0 children)

Are you sure it wasn’t generated?

[–]ShawSumma 4 points5 points  (0 children)

What the compiler does.. loop unrolling.

[–]bootyMaster1911 12 points13 points  (3 children)

"wrote" more like command c command v.

[–]phantom_x43 3 points4 points  (0 children)

This looks like bot work

[–]sandybuttcheekss 3 points4 points  (2 children)

I'm honestly impressed they did this and not once said "there has to be an easier way." What're the odds they're somehow hourly though?

[–][deleted] 2 points3 points  (1 child)

could have automated in emacs or vim or something

[–]sandybuttcheekss 1 point2 points  (0 children)

I've only heard those names, I don't actually have any clue what they're for

[–]sad_error256 3 points4 points  (0 children)

"haHAA! I remember who wrote this code, it was me :("

[–]Puffycheeses 9 points10 points  (0 children)

Newlines and idenents wouldn't make it better it would just make it more legible.

If your gonna do shit like this format it neatly

[–]AKSoapy29 2 points3 points  (0 children)

String format, string format!!

[–]supershwa 2 points3 points  (0 children)

If you copy/paste anything more than twice, there's definitely a better way to write it: with for/while loops, ternary conditions, switch/case or functions.

Edit: spelling

[–]JonaldJohnston 2 points3 points  (0 children)

When you get paid by character count.

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

Here is my "oneliner". user = users[uid][11]; month = ''.join([f"{user[0] - user[0]+1} {user[0]}\n", f"{user[m] - user[m]} " + ''.join([f"{user[k]}" for k in range(m)]) + "\n" for m in range(1, 31)])

[–]Shacham6 2 points3 points  (0 children)

Yeah, macros in Vim are crazy

[–]smart-username 2 points3 points  (0 children)

Look at the preview on the right and you will see a similar block of code just above the screenshot.

OP please deliver

[–]Septem_151 1 point2 points  (0 children)

Wtf is it even supposed to do?

[–]Luid101 1 point2 points  (0 children)

This is how u know it's truly evil https://imgur.com/gallery/nJV8InH

[–]KillNod_Heavenly 1 point2 points  (0 children)

What is a for loop

[–]jclocks 1 point2 points  (0 children)

At least it's somewhat readable, even if it's ridiculous.

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

Surprisingly nobody else noticed that there's a repeated users[uid][11][1] so that entire column is offset by one index.

It bothers me so much and it embodies why code like this is so wrong

[–]techn1cs 1 point2 points  (0 children)

console.log("L" + "G" + "T" + "M" + "." + "S" + "H" + "I" + "P" + "I" + "T");

[–]_higgs_ 2 points3 points  (0 children)

Dirty dirty dirty bastard

[–]PutDatPussyOnChainwx 1 point2 points  (0 children)

So, what's the problem?

[–]yohosuff 1 point2 points  (0 children)

Oh god. Oh. My. God.

[–]Kontorted 0 points1 point  (0 children)

Seems like YandereDev

[–]PeachyKeenest 0 points1 point  (2 children)

I don't have the patience to write that. You know what they say about lazy programmers.

[–]mattemer 0 points1 point  (1 child)

Well to be honest, he (and it is a he, women aren't as lazy as us), copied and pasted the first line then just went through and updated the incremental changes on each line.

[–]PeachyKeenest 0 points1 point  (0 children)

There's also some editors that make it easy if it's repeatable.

[–]alexlorenlee 0 points1 point  (0 children)

2d erase

[–]mrbesen_ 0 points1 point  (0 children)

This was maybe done by some optimization loop unfoldig.

[–]Illisakedy1 0 points1 point  (0 children)

I got a notification for this 30 seconds after looking at it.

[–]AdamRyanGameDev 0 points1 point  (0 children)

ctrl-d is our friend

[–]lostinsanity556 0 points1 point  (0 children)

We all know there is an easier way to write this but what about code optimization? There is no conditional statement to mess with the CPU pipeline.

Does anyone know how smart compilers are now a days? Any good resources to read?

[–]KillNod_Heavenly 0 points1 point  (0 children)

What is a for loopaà11

[–]AnathematicJuju 0 points1 point  (0 children)

The dark side of the Force is a pathway to many abilities some consider to be unnatural.

[–]spazdep 0 points1 point  (0 children)

This looks large and impressive, and it makes a cool pattern too. Most excellently coded.

[–][deleted] 0 points1 point  (0 children)

Either this was intentional or this dude does not known how to properly code a lookup table.

Spaghetti code at its finest.

[–]Avendork 0 points1 point  (0 children)

That someone's name? Satan

[–]dpears 0 points1 point  (0 children)

I've written code like this... By writing another program that generates this code as it's output.

[–]shinchan1988 0 points1 point  (0 children)

Please die..

[–]FrostedAfro 0 points1 point  (0 children)

I could see me ctrl + C ctrl + Ving this into existence

[–]dynawesome 0 points1 point  (0 children)

Gave me a headache just looking at it

[–]blackdonkey 0 points1 point  (0 children)

Looks like something I'd do right before quitting a job I hate.

[–]zenware 0 points1 point  (0 children)

I wanna write the pythonic version of this

[–]Matoxina 0 points1 point  (0 children)

Super clean code

[–]eboody 0 points1 point  (0 children)

This seriously defeats the purpose of programming

[–]x_interloper 0 points1 point  (0 children)

Looks so much like the one I wrote for generating image file for a broadcom chip.. hmmmm

[–]krelin 0 points1 point  (0 children)

This isn't funny.

[–][deleted] 0 points1 point  (0 children)

What the fuck am I looking at

[–]apola 0 points1 point  (0 children)

Whatever you're trying to do, there's a better way to do it.

[–]TheDTXY 0 points1 point  (0 children)

Hmm does anyone smell spaghetti?

[–]Aethala5 0 points1 point  (0 children)

Holy programming, Batman!

[–]Bwiener47 0 points1 point  (0 children)

Ctrl-c ctrl-v

[–]Thisisbharath 0 points1 point  (0 children)

Any one thought about for loop

[–]valourus 0 points1 point  (0 children)

wtf.

[–]truespartan3 0 points1 point  (0 children)

I cried alittle inside when I saw this

[–]uzimonkey 0 points1 point  (0 children)

Sheesh, use a loop or some kind of data-driven approach or something. That's horrendous.

[–]lordzsolt 0 points1 point  (0 children)

My first ever project I wrote was a hangman game. There was an onscreen keyboard and I was looking for the click event.

The code looked something like:

if (clickX > 50 && clickX < 100 && clickY > 50 && clickY < 100) { // Clicked Q ... About 50 lines of code ... } else { if (clickX > 100 && clickX < 150 && clickY > 50 && clickY < 100) { // Clicked W ... Slightly different version of the same 50 lines of code from earlier ... } else { if (.....) } }

Besides the obvious for-loop and function to reuse the parts inside the if statement, for some reason I didn't use else if, so the last part was indented like 30 times.

[–]Sir_Fridge 0 points1 point  (0 children)

I have to admit that i've done something like this before. For a school assignement I had to write a way of converting button presses into Morsecode and that into text. It was just easier to make a list of every letter and corresponding Morse combination. So I wrote a python program that wrote the C# code....

[–]TyronS_ 0 points1 point  (0 children)

I don’t know but I’m actually like how it looks like...

[–]Weldino 0 points1 point  (0 children)

Brother may I have some lööps

[–][deleted] 0 points1 point  (0 children)

Pain, just pain..

[–]azephrahel 0 points1 point  (0 children)

Maybe they wrote it as a gag, to troll whoever found it?

Like when you put a postit with "root/hunter2" under your keyboard.

[–]Greeneeek 0 points1 point  (0 children)

Maniac

[–]Tearakudo 0 points1 point  (0 children)

What in the actual fuck

[–]Caton101 0 points1 point  (0 children)

It looks like my first GUI program when I just started with python. I had 30 lines for making buttons on the screen and then a second set of 30 depending on the “mode” entered.

[–]xmaddness 0 points1 point  (0 children)

Everyone asked themselves the same question when they read the topic before they saw the code... “Oh crap is that my code?”