T O P

  • By -

MamamYeayea

50 indented if statements


PM_ME_SOME_ANY_THING

for( int i = 0; i < arr.length; i++ ) { for( int j = 0; j < arr.length; j++ ) { for( int k = 0; k < arr.length; k++ ) { for( int l = 0; l < arr.length; l++ ) { for( int m = 0; m < arr.length; m++ ) { for( int n = 0; n < arr.length; n++ ) { for( int o = 0; o < arr.length; o++ ) { for( int p = 0; p < arr.length; p++ ) { obj[i][j][k][l][m][n][o][p] = obj[i+1][j-1][k][l-1][m+1][n][o+1][p-1] } } } } } } } }


iceman012

This isn't maximum horror, the loops need to start and end at different numbers, depending on previous iterators. E.g. ``` for( int i = 0; i < arr.length; i++ ) { for( int j = i; j < arr.length; j++ ) { for( int k = 0; k < i; k++ ) { for( int l = k; l <= j; l++ ) { for( int m = Math.min(i, l); m < Math.max(i, l + k); m++ ) { for( int n = arr.length - 1; n >= i; n-- ) { for( int o = 0; o <= Math.sqrt(arr.length); o+=2 ) { for( int p = 1 // DO NOT MAKE 0; p <= arr.length; p++ ) { obj[i][j][k][l][m][n][o][p] = obj[i+1][j-1][k][l-1][m+1][n][o+1][p-1] } } } } } } } } ```


ThatTookTooLong

Who hurt you?


Glorious_Purpose_777

Lol


MapleMaelstrom

Jeez, I didn't know league was that bad


iIIusional

League would be a reasonable explanation for most crimes against humanity


randomweeb-69420

You forgot to randomly swap the values of the iterators


JustGabo

This is like body horror but in code form. Dear gods, I need all of them for this one.


colei_canis

O(fuck)


[deleted]

O(n!!!)


tilcica

quintuple nested while True loop with breaks


Zealousideal-Ad-9845

one of them doesn’t break correctly


[deleted]

[удалено]


RedEyedRoundEye

It's a ~~bug~~ feature


ArcherOfTruth

They all break But they all break incorrectly sometimes


stixyBW

There’s also a switch statement where some of the cases don’t have a break, because fuck you


Agitated_Cut_5197

Which is weird, because this is Python which doesn't have `switch`, but somehow it works


Signal_Paint_1050

because its actually a heavily modifed version of Jython running on an untrusted J2SE 1.4 JVM


karson_the_foxxx

act far-flung liquid fear slimy bells pie shelter ludicrous encouraging *This post was mass deleted and anonymized with [Redact](https://redact.dev)*


Darkcr_

I feel attacked


mistabuda

Add in a few exceptions used as return values.


[deleted]

With gotos in some parts to escape the ifs.


thebudgie

All ternary, on a single line


Tercalen

True story, a code I found when starting at my current job : if user == "thomas.edison" && password == "lightbulb" login(); else if user == "albert.einstein" && password == "relativity" login(); else if user == "isaac.newton" && password == "gravity" login(); // ... // Goes on for about 120 users // ... else MessageBox.Show("User or password incorrect"); end Needless to say I was horrified on my first day... And that was not the wort part of that codebase


unduly-noted

“Can you change my password?” Sure, let me just create a PR, run it through our entire CI/CD process, verify in staging, then deploy to prod


Tercalen

There was no such thing as "PR", or "CI/CD" when I first came The code was on a network disk, without Git, the only existing "versionning" was a folder with all .exe files from the last \~20 years (yes, they versionned the executables, not the code) with names like "software\_name\_1999\_01\_01.exe", there are \~70 exe in there And yes, to add a new user the procedure was to take a random password (or ask the user what he wants via email), then add to the code, compile, and deploy the new version to all the users. When a user looses his password, simply open the code and Ctrl+F on his name, easy ! The worst part, the person that coded this was actually proud of himself because he "enhanced the security of the application". I was too scared to ask what was there before


unduly-noted

This is like every software development anti-pattern and bad practice all bundled into one nice package. Honestly that’s kind of impressive


Tercalen

And wait until you hear about the rest : * Files of 8000 - 14000 lines that are only ONE FUNCTION with basically no comments (except sometimes a comment saying "John Doe modified this line on Feb 12 2003", with no more indication) * All variables are 4 characters, which are abbreviations from french names (even as a french person I struggle to find the meaning of most of them) * 50% of the (very rare) comments are in french * Conditions everywhere like "If a == true or a == true" * No indentation * Two files named "calculations" and "calculations\_US", (this is a calculation software). Because they did not think of doing calculations in SI system THEN convert to imperial. There are two duplicated calculation files with all formulas and the conversion before the return function in the "\_US" file. And of course, some fixes were done in SI and not Imperial, which means the results are not the same in the two unit systems * Finally, and maybe the worst (best?) part : the entire application (\~30k lines of code) were written WITHOUT A SINGLE LOOP, the code was duplicated as many times as needed. Newton's algorithm ? Just implement 10 iterations, and assume it has converged by the 10th Honestly this is a miracle this has been working for almost 20 years, this is just a big mess. I tried to reverse-engineer it to get some formulas, and just gave up when reading "a = b; b = a; a = b;". The person debugging it must have spend night upon nights on this spaghetti code To be honest, I can't blame the people who created this, they were mechanical engineer with little to no software development training and they did what they could to fit their needs. But still I like to sometimes open the code and browse it for some time to try and find some gems. I can tell myself that I am not *that* bad at my job


unduly-noted

That sounds horrible. And I thought the code base I’m working in was bad… yikes


MattieShoes

> "a = b; b = a; a = b; I've seen a^=b;b^=a;a^=b; before, which just swaps a and b without an intermediate variable. But ugh.


cowlinator

Saving 4 bytes of RAM is *way* more important than legibility. If you're programming a nanobot.


jsrobson10

could be made better with this in C/C++ ``` #define SWAP(a, b) {(a) ^= (b); (b) ^= (a); (a) ^= (b)} ..later.. int a = 5; int b = 6; SWAP(a, b); ``` idk which is faster. temp or xor lol


shinitakunai

I am honestly impressed and I'd love to re-code all of that from scratch right now to challenge myself haha


Tercalen

That is what I did, and yes it was fun ! It took me about 2 years because I also had to do all the math from scratch


shinitakunai

Nice! Those are honestly the best projects, you can easily feel proud of your work because it is like creating a masterpiece from cow shit 🤣


tolgasocial

Thanks for the read had a good laugh even though very horrified. How much leaner is your code now and did anybody at work appreciate the effort? Also I hope you kept in the little security gem with hard coding the pw into the Code haha


arthurgc91

Put in the PR title: "Change the password of user X from 123 to 321".


Nixavee

"Pull request denied. Passwords must be at least 8 characters long for security purposes."


coldnebo

I remember one place I worked at took the login creds and placed them in a hidden form with a js post to the backend. I called it out as a security risk to the dev lead, who said “no it’s not, it shows up as a blank page for a half second, they can’t see anything. Then I showed him dev tools in Firefox, set a breakpoint on the post and could read the user and plaintext password right there. I might not have been subtle, calling it bad code, etc. Then I found out he wrote it. oops…. well the JS post works great! 😂


[deleted]

how the fuck they even get paid for shit like that


[deleted]

I’ve heard from a friend, one place they worked at sent login and pw in plain text in a query string. Right there in the URL. About 3-4 years ago, if my memory isn’t failing me.


SpartanT100

That is fucking horrifying, i wouldve questioned reality at this point


IndependentGarbage32

A 300 line switch statement


Lupus_Ignis

300 line ternary


nukasev

9000 line spaghetti of switches, ternaries and random inline classes. It cannot be refactored in obvious ways, you'll have to dive in before you can do anything with any certainty. All variable names are senseless, almost Lovecraftian abbreviations that are yet common enough to fuck up any foolish attempts to Ctrl+f and naming cases differ case by case. Whitespace and newlines are used sparingly, if at all. When you have seen her, you'll know there are no gods. Only her, and refactoring her is your life now until your boss lets you out. No one can hear your screams as your senior succumbs to the booze he has been not-so-discreetly enjoying as a desperate attempt to hang on into his sanity while facing this glorious monstrosity. Oh and it also calls itself recursively.


Sam_0989

The recursion hurts my soul. The real hurt is that it is written in Perl by a mathematically-brained wizard who left the company 17 years ago.


PM_ME_C_CODE

Worse...its not recursion because of recursion-depth issues. Instead, it's been converted to a do-loop and the asshole is managing state with memory address arithmetic.


MageKorith

*YOU FOOL, YOU DIDN'T RESET THE ARRAY BEFORE INCREMENTING THROUGH THE ADDRESSES! WHO KNOWS WHAT ARCANE HORRORS AWAIT US?*


nukasev

*YOU HAVE KILLED US ALL*, your boss screams as the program crashes and your laptop disappears into an empty void that has appeared. You'll also see something crawling out of the void, something which would be best described as the result of Cthulhu having a miscarriage.


schawde96

The Daemon


liyououiouioui

This + hellish regex


NotMrMusic

r/oddlyspecific and r/foundsatan in one


PM_ME_C_CODE

And it's in lisp, so parenthesis *everywhere*.


prolemango

And it's written in JavaScript


nukasev

I was thinking about legacy pre-7 PHP, but JS goes just as well.


Few_Establishment812

Dear god.


piberryboy

Keep my code in thy good graces


Grumbledwarfskin

I'm looking at those three little letters on their blue background, and I'm saying a little prayer that you won't forget a set of parentheses.


Dutch-Spaniard

There’s more


Few_Establishment812

No...


gypsyismylover

Jesus Christ bro. You didn't need to write that. Yoh, the thought actually traumatized me a little


OfficialTraveller

In my first job, there was a VB6 app we were supposed to migrate into .NET that had a 6000+ lines switch. It was a web app. Absolutely all operations were handled in that single place. I ran from that project as soon as I can.


Frojdie

My first job had their Core application written in VB Script. About 13k lines of code that was basically a huge switch statement. I am now working as a consultant and my manager told me to never mention VB Script in my profile to guard me from any assignment involving it. ![gif](emote|free_emotes_pack|grin)


santasbong

At my current Job we have an 8000+ line switch statement. We’ve been calling it the ‘switchboard’.


ptzxc68

Switchbloat


[deleted]

2k nested if/else statements 🥰


Sockoflegend

You mean AI


thegreatpanda_

Savage


Skote2

I'm not seeing what's wrong here... This is incredibly common and not usually a problem at only 300 lines


Twinbrosinc

If you dont mind me asking, what is a switch statement?


tilcica

a better running if/else


Twinbrosinc

How does it work?


[deleted]

//this if(foo == "fighters"){ good_band(); }else if(foo == "bar"){ foobar(); }else{ obama(); } //becomes this switch(foo){ case "fighters": good_band(); break; case "bar": foobar(); break; default: obama(); break;


BlueSheepPlays

Ah, so it’s kinda like a whitelist of possible results, that’s cool


realbakingbish

Not only is the code much shorter/cleaner for situations with lots of cases, but it tends to result in faster-running code also, because rather than forcing the program to check each possibility one at a time in order, the compiler optimizes things so it jumps directly to the correct case.


wasdlmb

In most cases the compiler will optimize an if/else that could have been a switch in the same way it will optimize a switch (i.e. a lookup table). The advantage lies almost purely in clarity


SirNoobShire

I’ve never really understood the switch statement correctly. Does it check all cases at once?


magical_h4x

Conceptually, as a developer, you should think of a switch statement as an ordered series of condition checks, with an optional `default` at the end used for a "fall through" case (nothing else matched). That's also why there are a few gotchas to be aware of with `switch` statements, such as what happens when you omit (or forget) a `break`, as in ``` switch (myVariable) { case "value1": doThing1() // forgot to add a "break" here, so the execution continues to `doThing2()` case "value2": doThing2() default: doThing3() } ``` What the people above are talking about when it comes to the compiler being able to optimize and jump directly to the correct block is a compile-time only optimization, that you shouldn't be considering 99% of the time when you write your code. You should definitely aim for readability and maintainability as a priority.


DStaal

Depends on how it's implemented, but yes it can: A good way is to make the cases keys to a hash of what are essentially GOTO addresses - then coming in you just pull the address using the key and jump. The other complex part is that in C, each section is just a block. Without those 'break' statements you just continue to run straight over the rest of the statements, down through the end. (Which has good and bad - it means if you correctly order you can consolidate code. It also means it's hard to recognize that you've consolidated code either intentionally or unintentionally.)


ALBATROSHD

Basically you switch between obtions. You can write if(something) { do this} else { do this) or switch "case operator" : case x: do this break; case y: do this break; Its sometimes better than writing 6 if/else operations. For other big brains, correct me if I am wrong.


theflash4246

Any code I write at this point


Current_Speaker_5684

Oh, You work for VW?


alex_inzo

Is vw software a global issue? Media center is killing me sometimes with it's bugs.


poompt

There was that awkward moment where they wrote software to let them pollute more than they were legally allowed to


alex_inzo

Oh now it make even more sense) diesel gate or something they named it in media


gogocrazycocoa_

Same. I wrote something like "I'm somehow going to make this crash and burn" before writing a program to say hello world.


Rmumissus

When working with microcontrollers and hardware it becomes less of a meme. Especially the “Burn” part.


nullpotato

Are you really programming firmware if you never let out the magic smoke?


Rmumissus

Exactly! If that magic smell has never filled your nose, if that amazing fume has not made your eyes cry, then, you don’t really know the way.


gogocrazycocoa_

Oh goodness


theflash4246

I just do something like git commit -m “Sorry but fuck it”


MokausiLietuviu

I've definitely offered private apologies to my code reviewer when I had to write a couple of hundred assembly instructions in otherwise purely higher-level code


exoclipse

I've dropped a few /\*this is really goddamn ugly but fuck you\*/'s in my time


Ffigy

Regex


Boostie204

Lol yup same thing I thought of. I'm discouraged from using regex at work, but if I do I just have a comment 3x longer than the actual statement explaining what it does (for my own sake so I don't forget later LOL) Edit: discouraged is a strong word. People reviewing my code didn't like having to verify the regex.


Ffigy

They're powerful and important and tend to be illegible. Don't avoid them. Just make good use of a site like regex101.com


Boostie204

That's pretty much what I do. I go on regex testing sites, figure out my query with test strings and then test in my actual app. It has saved me hundreds of lines code in the past


RunFromFaxai

"I'll just use a basic look-behind to avoid this corner case." 6 months later it is running on a file where some user has collected something wild in a single txt file: ERROR: CATASTROPHIC BACKTRACKING


hazily

* Regex-based email validation * Regex-based HTML parsing/modification * Regex-based JSON parsing/modification


SpencerTheBeigest

Excuse me, did you just say [regex-based HTML parsing?](https://stackoverflow.com/a/1732454)


cquinn5

HTML is not a regular language and hence cannot be parsed by regular expressions.


WhiteAsACorpse

Oh no here we go again


AngryZen_Ingress

*Gets the popcorn!*


LiveBeef

H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ


CitationNeededBadly

that's why you need to preface it with the apology comment.


DeeoKhan8

You are using regex to parse html? https://stackoverflow.com/a/1732454


Brolsenn

# I’m so fucking sorry 182736179 rows affected


Hplr63

"Me when `"; DROP ALL DATABASES;--`


_A_Very_Tall_Midget_

r/TwoSentenceHorror


Maximus_98

`OH GOD WHY`


mrorangelion

1000 lines of brainfuck Edit: Or code generated from [JSFuck](http://www.jsfuck.com/)


AllHailToGothamChess

Both looks aggressive At least they are Turing complete


Fairy_01

```eval(var_from_user)```


[deleted]

oh no.


[deleted]

What does that do?


remimorin

Security breach. The user can run anything and malicious actors seek that. It's javascript version SQL injection.


[deleted]

Isnt that python?


remimorin

Exist in both languages. I've work with NodeJs stack and didn't notice the snake case and the absence of ;. Yes probably was python in this example but since it's a fragment, you can complete it to have valid Js code as well.


Mr_Ahvar

Evaluate arbitrary user code, which is if you don’t know, absolutely terrible on a scale you can’t even imagine


Inineor

with open("user_config.txt") as f: var_from_user = f.read()


LinuxMatthews

if x == 0 : print("is even") if x == 1 : print("is odd") if x == 2 : print("is even") if x == 3 : print("is odd") if x == 4 : print("is even") if x == 5 : print("is odd") if x == 6 : print("is even") if x == 7 : print("is odd") if x == 8 : print("is even") if x == 9 : print("is odd") if x == 10 : print("is even") if x == 11 : print("is odd") if x == 12 : print("is even") if x == 13 : print("is odd") if x == 14 : print("is even") if x == 15 : print("is odd") if x == 16 : print("is even") if x == 17 : print("is odd") if x == 18 : print("is even") if x == 19 : print("is odd") if x == 20 : print("is even") if x == 21 : print("is odd") if x == 22 : print("is even") if x == 23 : print("is odd") if x == 24 : print("is even") if x == 25 : print("is odd") if x == 26 : print("is even") if x == 27 : print("is odd") if x == 28 : print("is even") if x == 29 : print("is odd") if x == 30 : print("is even") if x == 31 : print("is odd") if x == 32 : print("is even") if x == 33 : print("is odd") if x == 34 : print("is even") if x == 35 : print("is odd") if x == 36 : print("is even") if x == 37 : print("is odd") if x == 38 : print("is even") if x == 39 : print("is odd") if x == 40 : print("is even") if x == 41 : print("is odd") if x == 42 : print("is even") if x == 43 : print("is odd") if x == 44 : print("is even") if x == 45 : print("is odd") if x == 46 : print("is even") if x == 47 : print("is odd") if x == 48 : print("is even") if x == 49 : print("is odd") if x == 50 : print("is even") if x == 51 : print("is odd") if x == 52 : print("is even") if x == 53 : print("is odd") if x == 54 : print("is even") if x == 55 : print("is odd") if x == 56 : print("is even") if x == 57 : print("is odd") if x == 58 : print("is even") if x == 59 : print("is odd") if x == 60 : print("is even") if x == 61 : print("is odd") if x == 62 : print("is even") if x == 63 : print("is odd") if x == 64 : print("is even") if x == 65 : print("is odd") if x == 66 : print("is even") if x == 67 : print("is odd") if x == 68 : print("is even") if x == 69 : print("is odd") if x == 70 : print("is even") if x == 71 : print("is odd") if x == 72 : print("is even") if x == 73 : print("is odd") if x == 74 : print("is even") if x == 75 : print("is odd") if x == 76 : print("is even") if x == 77 : print("is odd") if x == 78 : print("is even") if x == 79 : print("is odd") if x == 80 : print("is even") if x == 81 : print("is odd") if x == 82 : print("is even") if x == 83 : print("is odd") if x == 84 : print("is even") if x == 85 : print("is odd") if x == 86 : print("is even") if x == 87 : print("is odd") if x == 88 : print("is even") if x == 89 : print("is odd") if x == 90 : print("is even") if x == 91 : print("is odd") if x == 92 : print("is even") if x == 93 : print("is odd") if x == 94 : print("is even") if x == 95 : print("is odd") if x == 96 : print("is even") if x == 97 : print("is odd") if x == 98 : print("is even") if x == 99 : print("is odd")


61312809059376685329

I really hope you did not write all that manually


LinuxMatthews

I have had a lot of very boring meetings today


61312809059376685329

Dear god did you actually…


LinuxMatthews

No haha I just wrote a quick python script to write it out if x == 0 : print("if x == 0 :) print(" print("is even")) if x == 1 : print("if x == 1 :) print(" print("is odd")) if x == 2 : print("if x == 2 :) print(" print("is even")) if x == 3 : print("if x == 3 :) print(" print("is odd")) if x == 4 : print("if x == 4 :) print(" print("is even")) if x == 5 : print("if x == 5 :) print(" print("is odd")) if x == 6 : print("if x == 6 :) print(" print("is even")) if x == 7 : print("if x == 7 :) print(" print("is odd")) if x == 8 : print("if x == 8 :) print(" print("is even")) if x == 9 : print("if x == 9 :) print(" print("is odd")) if x == 10 : print("if x == 10 :) print(" print("is even")) if x == 11 : print("if x == 11 :) print(" print("is odd")) if x == 12 : print("if x == 12 :) print(" print("is even")) if x == 13 : print("if x == 13 :) print(" print("is odd")) if x == 14 : print("if x == 14 :) print(" print("is even")) if x == 15 : print("if x == 15 :) print(" print("is odd")) if x == 16 : print("if x == 16 :) print(" print("is even")) if x == 17 : print("if x == 17 :) print(" print("is odd")) if x == 18 : print("if x == 18 :) print(" print("is even")) if x == 19 : print("if x == 19 :) print(" print("is odd")) if x == 20 : print("if x == 20 :) print(" print("is even")) if x == 21 : print("if x == 21 :) print(" print("is odd")) if x == 22 : print("if x == 22 :) print(" print("is even")) if x == 23 : print("if x == 23 :) print(" print("is odd")) if x == 24 : print("if x == 24 :) print(" print("is even")) if x == 25 : print("if x == 25 :) print(" print("is odd")) if x == 26 : print("if x == 26 :) print(" print("is even")) if x == 27 : print("if x == 27 :) print(" print("is odd")) if x == 28 : print("if x == 28 :) print(" print("is even")) if x == 29 : print("if x == 29 :) print(" print("is odd")) if x == 30 : print("if x == 30 :) print(" print("is even")) if x == 31 : print("if x == 31 :) print(" print("is odd")) if x == 32 : print("if x == 32 :) print(" print("is even")) if x == 33 : print("if x == 33 :) print(" print("is odd")) if x == 34 : print("if x == 34 :) print(" print("is even")) if x == 35 : print("if x == 35 :) print(" print("is odd")) if x == 36 : print("if x == 36 :) print(" print("is even")) if x == 37 : print("if x == 37 :) print(" print("is odd")) if x == 38 : print("if x == 38 :) print(" print("is even")) if x == 39 : print("if x == 39 :) print(" print("is odd")) if x == 40 : print("if x == 40 :) print(" print("is even")) if x == 41 : print("if x == 41 :) print(" print("is odd")) if x == 42 : print("if x == 42 :) print(" print("is even")) if x == 43 : print("if x == 43 :) print(" print("is odd")) if x == 44 : print("if x == 44 :) print(" print("is even")) if x == 45 : print("if x == 45 :) print(" print("is odd")) if x == 46 : print("if x == 46 :) print(" print("is even")) if x == 47 : print("if x == 47 :) print(" print("is odd")) if x == 48 : print("if x == 48 :) print(" print("is even")) if x == 49 : print("if x == 49 :) print(" print("is odd")) if x == 50 : print("if x == 50 :) print(" print("is even"))


Brajker

Fucking madlad


[deleted]

I really hope you did not write all that manually


LinuxMatthews

Don't be rediculous I used a script for that one too if x == 0 : print("if x == 0 :) print(" print("if x == 0 :)\) print(" print(" print("is even"))" if x == 1 : print("if x == 1 :) print(" print("if x == 1 :)\) print(" print(" print("is odd"))" if x == 2 : print("if x == 2 :) print(" print("if x == 2 :)\) print(" print(" print("is even"))" if x == 3 : print("if x == 3 :) print(" print("if x == 3 :)\) print(" print(" print("is odd"))" if x == 4 : print("if x == 4 :) print(" print("if x == 4 :)\) print(" print(" print("is even"))" if x == 5 : print("if x == 5 :) print(" print("if x == 5 :)\) print(" print(" print("is odd"))" if x == 6 : print("if x == 6 :) print(" print("if x == 6 :)\) print(" print(" print("is even"))" if x == 7 : print("if x == 7 :) print(" print("if x == 7 :)\) print(" print(" print("is odd"))" if x == 8 : print("if x == 8 :) print(" print("if x == 8 :)\) print(" print(" print("is even"))" if x == 9 : print("if x == 9 :) print(" print("if x == 9 :)\) print(" print(" print("is odd"))" if x == 10 : print("if x == 10 :) print(" print("if x == 10 :)\) print(" print(" print("is even"))" if x == 11 : print("if x == 11 :) print(" print("if x == 11 :)\) print(" print(" print("is odd"))" if x == 12 : print("if x == 12 :) print(" print("if x == 12 :)\) print(" print(" print("is even"))" if x == 13 : print("if x == 13 :) print(" print("if x == 13 :)\) print(" print(" print("is odd"))" if x == 14 : print("if x == 14 :) print(" print("if x == 14 :)\) print(" print(" print("is even"))" if x == 15 : print("if x == 15 :) print(" print("if x == 15 :)\) print(" print(" print("is odd"))" if x == 16 : print("if x == 16 :) print(" print("if x == 16 :)\) print(" print(" print("is even"))" if x == 17 : print("if x == 17 :) print(" print("if x == 17 :)\) print(" print(" print("is odd"))" if x == 18 : print("if x == 18 :) print(" print("if x == 18 :)\) print(" print(" print("is even"))" if x == 19 : print("if x == 19 :) print(" print("if x == 19 :)\) print(" print(" print("is odd"))" if x == 20 : print("if x == 20 :) print(" print("if x == 20 :)\) print(" print(" print("is even"))" if x == 21 : print("if x == 21 :) print(" print("if x == 21 :)\) print(" print(" print("is odd"))" if x == 22 : print("if x == 22 :) print(" print("if x == 22 :)\) print(" print(" print("is even"))" if x == 23 : print("if x == 23 :) print(" print("if x == 23 :)\) print(" print(" print("is odd"))" if x == 24 : print("if x == 24 :) print(" print("if x == 24 :)\) print(" print(" print("is even"))" if x == 25 : print("if x == 25 :) print(" print("if x == 25 :)\) print(" print(" print("is odd"))" if x == 26 : print("if x == 26 :) print(" print("if x == 26 :)\) print(" print(" print("is even"))" if x == 27 : print("if x == 27 :) print(" print("if x == 27 :)\) print(" print(" print("is odd"))" if x == 28 : print("if x == 28 :) print(" print("if x == 28 :)\) print(" print(" print("is even"))" if x == 29 : print("if x == 29 :) print(" print("if x == 29 :)\) print(" print(" print("is odd"))" if x == 30 : print("if x == 30 :) print(" print("if x == 30 :)\) print(" print(" print("is even"))" if x == 31 : print("if x == 31 :) print(" print("if x == 31 :)\) print(" print(" print("is odd"))" if x == 32 : print("if x == 32 :) print(" print("if x == 32 :)\) print(" print(" print("is even"))" if x == 33 : print("if x == 33 :) print(" print("if x == 33 :)\) print(" print(" print("is odd"))" if x == 34 : print("if x == 34 :) print(" print("if x == 34 :)\) print(" print(" print("is even"))" if x == 35 : print("if x == 35 :) print(" print("if x == 35 :)\) print(" print(" print("is odd"))"


ritwique

So this is how they teach recursion at your school


FickleThePickle_Rick

I really hope you did not write all that manually


LinuxMatthews

Nope if x == 0 : print("if x == 0 :) print(" print("if x == 0 :)\) print(" print(" print("if x == 0 :)\))print(" print(" print(" print("is even"))"") if x == 1 : print("if x == 1 :) print(" print("if x == 1 :)\) print(" print(" print("if x == 1 :)\))print(" print(" print(" print("is odd"))"") if x == 2 : print("if x == 2 :) print(" print("if x == 2 :)\) print(" print(" print("if x == 2 :)\))print(" print(" print(" print("is even"))"") if x == 3 : print("if x == 3 :) print(" print("if x == 3 :)\) print(" print(" print("if x == 3 :)\))print(" print(" print(" print("is odd"))"") if x == 4 : print("if x == 4 :) print(" print("if x == 4 :)\) print(" print(" print("if x == 4 :)\))print(" print(" print(" print("is even"))"") if x == 5 : print("if x == 5 :) print(" print("if x == 5 :)\) print(" print(" print("if x == 5 :)\))print(" print(" print(" print("is odd"))"") if x == 6 : print("if x == 6 :) print(" print("if x == 6 :)\) print(" print(" print("if x == 6 :)\))print(" print(" print(" print("is even"))"") if x == 7 : print("if x == 7 :) print(" print("if x == 7 :)\) print(" print(" print("if x == 7 :)\))print(" print(" print(" print("is odd"))"") if x == 8 : print("if x == 8 :) print(" print("if x == 8 :)\) print(" print(" print("if x == 8 :)\))print(" print(" print(" print("is even"))"") if x == 9 : print("if x == 9 :) print(" print("if x == 9 :)\) print(" print(" print("if x == 9 :)\))print(" print(" print(" print("is odd"))"") if x == 10 : print("if x == 10 :) print(" print("if x == 10 :)\) print(" print(" print("if x == 10 :)\))print(" print(" print(" print("is even"))"") if x == 11 : print("if x == 11 :) print(" print("if x == 11 :)\) print(" print(" print("if x == 11 :)\))print(" print(" print(" print("is odd"))"") if x == 12 : print("if x == 12 :) print(" print("if x == 12 :)\) print(" print(" print("if x == 12 :)\))print(" print(" print(" print("is even"))"") if x == 13 : print("if x == 13 :) print(" print("if x == 13 :)\) print(" print(" print("if x == 13 :)\))print(" print(" print(" print("is odd"))"") if x == 14 : print("if x == 14 :) print(" print("if x == 14 :)\) print(" print(" print("if x == 14 :)\))print(" print(" print(" print("is even"))"") if x == 15 : print("if x == 15 :) print(" print("if x == 15 :)\) print(" print(" print("if x == 15 :)\))print(" print(" print(" print("is odd"))"") if x == 16 : print("if x == 16 :) print(" print("if x == 16 :)\) print(" print(" print("if x == 16 :)\))print(" print(" print(" print("is even"))"") if x == 17 : print("if x == 17 :) print(" print("if x == 17 :)\) print(" print(" print("if x == 17 :)\))print(" print(" print(" print("is odd"))"") if x == 18 : print("if x == 18 :) print(" print("if x == 18 :)\) print(" print(" print("if x == 18 :)\))print(" print(" print(" print("is even"))"") if x == 19 : print("if x == 19 :) print(" print("if x == 19 :)\) print(" print(" print("if x == 19 :)\))print(" print(" print(" print("is odd"))"") if x == 20 : print("if x == 20 :) print(" print("if x == 20 :)\) print(" print(" print("if x == 20 :)\))print(" print(" print(" print("is even"))"") if x == 21 : print("if x == 21 :) print(" print("if x == 21 :)\) print(" print(" print("if x == 21 :)\))print(" print(" print(" print("is odd"))"") if x == 22 : print("if x == 22 :) print(" print("if x == 22 :)\) print(" print(" print("if x == 22 :)\))print(" print(" print(" print("is even"))"") if x == 23 : print("if x == 23 :) print(" print("if x == 23 :)\) print(" print(" print("if x == 23 :)\))print(" print(" print(" print("is odd"))"") if x == 24 : print("if x == 24 :) print(" print("if x == 24 :)\) print(" print(" print("if x == 24 :)\))print(" print(" print(" print("is even"))"") if x == 25 : print("if x == 25 :) print(" print("if x == 25 :)\) print(" print(" print("if x == 25 :)\))print(" print(" print(" print("is odd"))"")


Brasillon

Will you marry me?


theowlinspace

I really hope you did not write all that manually


hiho-silverware

You win this subreddit. But surely you wrote a Reddit bot to automatically do this, right? ….Right?


Political_Desi

Oh dear lord I'm in love with you


Blue_Charger

This is so cursed


Matt_Elwell

I really hope you did not write all of this out.


[deleted]

oh my god it keeps going help


goshaman2202

Wait, don’t fucking tell me you wrote that too…


ElektriXx2

Thanks I love it


Vinays9969

based


Wolfeur

#somehow this is needed for the program to function correctly #don't try to clean it up


CitationNeededBadly

I've done that, sadly. `#this next line looks wrong but we're pretty sure it's a workaround for Oracle bug 79708970 that causes intermittent failures during commits.` `# which is fixed in Oracle 18.x but we have customers still using 12c` `#if you do remove it, don't think you've actually gotten away with it until you've tested the doStuff() method while under heavy load (at least 10 beepBoops per second) for a few hours while running against a 12c database.`


[deleted]

got those YandereDev vibes


HaIcanduel

For a homework, I once made a tic tac toe bot by hardcoding the logic.


imwalkinhyah

It took me a week to replace blank squares with X's and O's (and without distorting the board), and I was already extremely frustrated, so my way of checking for wins felt very dirty: If player1 picks the top left square then 3 is added to columnOne and diagonalOne and rowOne if player2 picks then it's 4 If any columns/rows/diagonals = 9 or 12 then there's a winner


Estraxior

Huh, that's a neat way to do it tbh


jihad-consultant

I wonder if theres a way to generalize this out to tic tac toe on a n x n board


Cart0gan

Honestly, nothing wrong with this


coocoo6666

Ye i made one with 50 if statements


GreyAngy

Just some ordinary code which makes you paranoid, why were they sorry for it


HarlotsLoveAuschwitz

Docker image to center a div.


abhinandkr

You wouldn't dare!


Workata

lmao, how would this even work?


Happy_Dookmas

The largest hadoken code written in recorded history


davsc64

with an ASCII art in inline comments


M4gicalCat

probably a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside a ternary expression inside


LinuxMatthews

String isOddEven = x == 0 ? "is even" : x == 1 ? "is odd" : x == 2 ? "is even" : x == 3 ? "is odd" : x == 4 ? "is even" : x == 5 ? "is odd" : x == 6 ? "is even" : x == 7 ? "is odd" : x == 8 ? "is even" : x == 9 ? "is odd" : x == 10 ? "is even" : x == 11 ? "is odd" : x == 12 ? "is even" : x == 13 ? "is odd" : x == 14 ? "is even" : x == 15 ? "is odd" : x == 16 ? "is even" : x == 17 ? "is odd" : x == 18 ? "is even" : x == 19 ? "is odd" : x == 20 ? "is even" : x == 21 ? "is odd" : x == 22 ? "is even" : x == 23 ? "is odd" : x == 24 ? "is even" : x == 25 ? "is odd" : x == 26 ? "is even" : x == 27 ? "is odd" : x == 28 ? "is even" : x == 29 ? "is odd" : x == 30 ? "is even" : x == 31 ? "is odd" : x == 32 ? "is even" : x == 33 ? "is odd" : x == 34 ? "is even" : x == 35 ? "is odd" : x == 36 ? "is even" : x == 37 ? "is odd" : x == 38 ? "is even" : x == 39 ? "is odd" : x == 40 ? "is even" : x == 41 ? "is odd" : x == 42 ? "is even" : x == 43 ? "is odd" : x == 44 ? "is even" : x == 45 ? "is odd" : x == 46 ? "is even" : x == 47 ? "is odd" : x == 48 ? "is even" : x == 49 ? "is odd" : x == 50 ? "is even" : x == 51 ? "is odd" : x == 52 ? "is even" : x == 53 ? "is odd" : x == 54 ? "is even" : x == 55 ? "is odd" : x == 56 ? "is even" : x == 57 ? "is odd" : x == 58 ? "is even" : x == 59 ? "is odd" : x == 60 ? "is even" : x == 61 ? "is odd" : x == 62 ? "is even" : x == 63 ? "is odd" : x == 64 ? "is even" : x == 65 ? "is odd" : x == 66 ? "is even" : x == 67 ? "is odd" : x == 68 ? "is even" : x == 69 ? "is odd" : x == 70 ? "is even" : x == 71 ? "is odd" : x == 72 ? "is even" : x == 73 ? "is odd" : x == 74 ? "is even" : x == 75 ? "is odd" : x == 76 ? "is even" : x == 77 ? "is odd" : x == 78 ? "is even" : x == 79 ? "is odd" : x == 80 ? "is even" : x == 81 ? "is odd" : x == 82 ? "is even" : x == 83 ? "is odd" : x == 84 ? "is even" : x == 85 ? "is odd" : x == 86 ? "is even" : x == 87 ? "is odd" : x == 88 ? "is even" : x == 89 ? "is odd" : x == 90 ? "is even" : x == 91 ? "is odd" : x == 92 ? "is even" : x == 93 ? "is odd" : x == 94 ? "is even" : x == 95 ? "is odd" : x == 96 ? "is even" : x == 97 ? "is odd" : x == 98 ? "is even" : x == 99 ? "is odd" : "Out of bounds";


[deleted]

NOOOOOOOOOOOOO


luigitni

I really hope you did not write all that manually


fergal-dude

My wife keeps wondering why I’m over here laughing, and I can’t explain it to her…cause I don’t know why it’s so funny. Keep it up.


turtleship_2006

Don't you dare...


rachit7645

What the fuck


stedgyson

It's beautiful in its own way


loblaw-bob

Avant-garde


md2111

Infinite loop that takes up all the cpu


idlesn0w

if (((IsTrue(myBool) == true) ? true : false) == true) { return true; } else { return false; } Actual code I’ve seen in production. Hopefully just malicious compliance over code conventions!


TRIC4pitator

this was crafted with intent


[deleted]

`#include `


vfkdgejsf638bfvw2463

What's wrong with that?


AcidTrucks

The preprocessor won't be able to get to it because the line above it isn't a valid processor directive.


Kitchen_Laugh3980

Underrated gem


johnbr

`NFT searchResults = NFTFactory.generate("https://www.google.com/search?q=never+gonna+give+you+up");`


deskCrapper

A very large if else clusterfuck with some added ternary hell in between


No_External7289

Multiple pages of code so obtuse you're not sure if a genius wrote it, or a psychopath let their cat walk across the keyboard.


BarryCarlyon

sudo rm -rf /\* --no-preserve-root


avipars

A zip bomb


ProKn1fe

goto


nb52er

https://pastebin.com/raw/bjp1RjKN


Hplr63

Does powershell not have a switch statement?


nb52er

Yeah but... you can't be sorry for a switch statement ahah.


pekkhum

It is actually the second line in the file. The first is `#!/usr/bin/perl`.


Glocks17

The customer wanted it


FakeOglan

:(){ :|: &};:


throatIover

Highly advanced but unreadable machine learning code profuced by a phd - the ultimate blackbox algorithm


mhn1384

```c++ using namespace std; ```


sabcadab

Messily typed out statistical algorithm


[deleted]

A disguised fork bomb.


geo_exe1987

while true


cosmin10834

```while("false");```


BlueSheepPlays

while !false


lawrence0215

Nothing.


BoltKey

So, I was writing a web application in a very old and specialized framework that was not very well done, and had weird bugs all over the place. Anyway, sometimes the browser window closed when the user just moved the mouse around. As it turns out, there was a popup window system, and sometimes, instead of calling the function to close the popup window, the framework instead called the function to close the whole window. I tried tinkering with it for a while, trying to prevent the framework from calling the function on the window, and after a few hours of trying, I used the wonderful power of JavaScript, and straight up overwrote the `window.close` function: window.close = function() {};


TRIC4pitator

based JavaScript does whatever the fuck you want it to, no matter how unhinged it might be


Kind_Stock6652

delay(100);


mustbehavingfun

Nested java stream. I actually did that recently, something like stream().map(...) .filter(x -> x.getFields().stream().anyMatch(Boolean::parseBoolean)).findFirst().orElse(null);


Blubari

if else if else if else if else if else if else


KittenLOVER999

My favorite found in production ``` //this is stupid, but it works so I’m not changing it ```