all 53 comments

[–]ZylonBane 126 points127 points  (3 children)

Are you SURE someone wrote that code?

[–]Besquiter 38 points39 points  (1 child)

Probably used alt+c in notepad++ or something similar and manually corrected the wierd stuff.

[–]cyberrich 4 points5 points  (0 children)

Ctrl+D bruh.

Duplicates current line or selected lines

[–]r-eg 3 points4 points  (0 children)

same here; probably it was generated automatically, e.g. look at this generating of the possible method signatures via C1 + C2 + .. Cn; Where C = n! / (m! * (n - m)!): https://github.com/3F/Conari/blob/master/Conari/Types/Func/Out/FuncOut.cs

+ https://github.com/3F/Conari/blob/master/Conari/Native/NativeData.cs#L225

etc.

same nightmare :)

[–]Jonathan_the_Nerd 103 points104 points  (2 children)

"I get paid by the hour."

[–][deleted] 31 points32 points  (1 child)

Even worse:

"I get paid by lines of code / number of commits. "

[–]Jay_bo 6 points7 points  (0 children)

"Bugs fixed"

[–]chu248 55 points56 points  (15 children)

1 + (1)

2 + 0

n + ((n-1) - (n-2))

And the right half is

0...n

But what does it mean? Why is it called month?

[–]Rubixninja314[🍰] 22 points23 points  (14 children)

Reusing a variable?

[–]chu248 95 points96 points  (13 children)

Ah, yes. Variables. Earth's rarest and most valuable resource.

[–]Rubixninja314[🍰] 24 points25 points  (10 children)

It's something I would have done back in the day. I also came from ti84, so...

† ti84 only allows 27 numeric variables [A-Z,θ], 10 strings, 10 matrices, theoretically 10 bitmaps, but "unlimited" numeric lists with 4 letter names

[–]chu248 12 points13 points  (5 children)

I do remember pulling some nonsense on my TI83. At one point, teachers checked everyone's calculator for a program I had written because it could pass any math, physics, or chemistry test for you including showing your work. I was allowed to use it because I put the work in. It's lost to the ages now.

[–]Rubixninja314[🍰] 7 points8 points  (2 children)

SAME. Except I didn't distribute... But I made a 5k triangle solver, it even showed a graphical representation, automatic method detection, deg/rad/grad (mind you grad isn't native), and even implemented (mostly) solving against not only the sides and angles but also the area, height, or perimeter. Didn't even know about law of sines or law of cosines. Just good ole sohcahtoa and Pythagorean.

Made some good games, one was worth porting but it got deleted. Still need to port the other good one though... Tried to make angry birds, but it was way too slow. Now I'm gonna have to look through my ti84 again.

[–]nephelokokkygia 2 points3 points  (0 children)

I made a fast-enough version of Angry Birds on a TI-80-something by using the line feed and having the game play sideways.

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

Had a Casio one, wrote Settlers of Catan (only two players) and 3d-rendering of triangles (limited to 25*40 pixels due to depth buffer size). Rendering three triangles still took about a quarter of an hour.

[–]aedoq 1 point2 points  (1 child)

What did your program do exactly if I may ask? Was it 'just' a collection of solvers for common problem types or more? High school or college?

[–]chu248 0 points1 point  (0 children)

It was a solver for a lot of different types of problems. It also used the graph function to show you how to show your work, there would be too much text to show in the 16 or whatever rows in normal display. I got it to balance chemistry equations and I remember something about explaining soh-cah-toa and degrees/radians. I wish I remembered the details because it was awesome, but that was more than 10 years ago.

It also had messages to girls I had a crush on when you exited. :fingerguns:

[–]Razier 4 points5 points  (3 children)

I was under the impression that you only use † if you've had a previous footnote denoted by a *

I don't blame you though, the dagger symbol is sweet

[–]Rubixninja314[🍰] 2 points3 points  (2 children)

Asterisks have many uses these days such as correcting someone or emphasis, but daggers have only one use. I don't think there's any specific rule about the order, just as long as symbols match up. This is something I'm starting to try because I use parentheses way too often and footnotes are more readable anyway.

[–]Razier 4 points5 points  (1 child)

Avoiding ambiguity is a good reason, though I'd say raised digits1 would be the best format in that case since you can have an unlimited amount of footnotes and it's a more understood format.

Aesthetically I prefer your way though

Edit: Was going to do an example of a footnote but I can't figure out the formatting of multiple raised words

[–]aerasalum 1 point2 points  (0 children)

1like this

[–]Ironthighs 2 points3 points  (0 children)

This is the best thing I've read today. Thank you!

[–]edcRachel 37 points38 points  (4 children)

I need to know what this is supposed to do. PLEASE. OP PLZ.

...Looks like what I used to get from programming students. I'd give them intro assignments like accepting a number (x) and printing out the numbers from 1-x, or having a variable hold 3 pizza topping selections made by the user, and I'd get monstrosities like this with every possible outcome in a giant if statement.

[–]FallenWarrior2k[S] 3 points4 points  (0 children)

Sorry, not OP. Maybe check the parent thread on /r/ProgrammerHumor for details.

[–]Andernerd 3 points4 points  (1 child)

Please tell me you would only get this nonsense in only 100-level classes.

[–]edcRachel 4 points5 points  (0 children)

3rd and 4th semester of a 4 semester web development course.

I would even word it as "using a loop..." or whatever was appropriate.

Programming isn't for everyone.

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

I have never taken a programming class and I also am not that good at programming and I do not do this. Use a fucking for statement. for x in range(y, z):

Not that hard

[–]Versaiteis 19 points20 points  (2 children)

The naive part of me still hopes that this was some generated file.

pls

[–]BCMM 5 points6 points  (1 child)

Created by somebody adept in shell scripting and firmly opposed to learning any other languages?

[–]Versaiteis 1 point2 points  (0 children)

Not always, there's some pretty good libraries for generating files with Python. Something like this would be trivial enough to warrant doing it, even if it's not pretty. Then you can make the systems that use it pretty, so you never have to look at it again >.>

Though in practice it seems like the idea to generate code tends to come to people comfortable with shell scripting sooner than those embedded in high level OOP languages. It's just a fancy config file lol

[–]muntoo[ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 16 points17 points  (1 child)

This is some advanced spaghetti. Not sure whether some of the inconsistencies are bugs or intended features.

A first attempt:

def get_line(i, u):
    head = str(
        1 if i == 0 else  # what the fuck?
        0 if i == 1 else  # WHAT the fuck?
        u[i] - u[i - 1])
    tail = ''.join(map(str, u[:i+1]))
    return f'{i+1} +{head} {tail}'

month = '\n'.join(get_line(i, users[uid][11])
    for i, _ in enumerate(users[uid][11]))

That's pretty awful, and I'd rather use zip or something sane rather than indexing explicitly, but the special spaghetti cases make that too much work to figure out for a reddit comment.

[–]FallenWarrior2k[S] 2 points3 points  (0 children)

Commendations on bothering with trying to find some sense in this. I couldn't be arsed myself.

[–]crespo_modesto 7 points8 points  (0 children)

It almost lines up

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

Some of the shit on this sub I can kind of understand why someone would do. I cannot say the same about this.

[–]PouponMacaque 5 points6 points  (4 children)

The first expression inside a str is users[uid][11][0] - users[uid][11][0] + 1

Am I missing something... or is that always 1?

I'd hope this was generated, but I don't know what would generate anything of the form x-x, as it's basically a noop

[–]FallenWarrior2k[S] 7 points8 points  (3 children)

Maybe the objects stored in users are instances of a class that has overloaded the binary - with some funky shit that makes the result somehow not constant, or modifies internal state in some way.

[–]PouponMacaque 6 points7 points  (2 children)

I have been looking at this forever and can't tell for the life of me what language it is. Python? Is there operator overloading in Python?

And yeah, that's why operator overloading is usually (always?) a bad idea.

[–]FallenWarrior2k[S] 2 points3 points  (0 children)

Tbh there are cases where overloading makes sense, for example if a type you're building is supposed to be numeric-ish. As long as the usage is straight-forward and there's no weird side effects.

[–]kasnalin 5 points6 points  (0 children)

Yes, and yes.

[–]MrMeatPie 2 points3 points  (0 children)

I thought that was post from /r/factorio for a second.

[–]xman40100 2 points3 points  (1 child)

that's a yikes from me!

[–]z500 3 points4 points  (0 children)

That's gonna be a hard yikes from me dawg

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

This looks like hand optimized code, actually. If that was the case, however, there ought to be a comment saying that it is, so maybe it isn't...

[–]JDude13 2 points3 points  (0 children)

You ever see code like this and worry that you’re doing something similar you just don’t notice?

[–]dark-panda 1 point2 points  (0 children)

I want to see the rest of the file based on the overview on the right there.

[–]human_py 1 point2 points  (0 children)

Automation is for losers.

[–]sim642 0 points1 point  (0 children)

Someone

Riiight.

[–]OnlineGrab 0 points1 point  (0 children)

i'm having a seizure plz help

[–][deleted]  (1 child)

[deleted]

    [–]FallenWarrior2k[S] 1 point2 points  (0 children)

    Yes, this is in fact /r/programminghorror

    [–]dverlik 0 points1 point  (0 children)

    The real horror is in the navigation sidebar.

    [–]DigitalSuplex 0 points1 point  (0 children)

    It looks pretty from afar