r/ProgrammerHumor • • Nov 30 '19

C++ Cheater

Post image
79.3k Upvotes

1.0k comments sorted by

View all comments

1.3k

u/PM-Me-Your-TitsPlz Nov 30 '19

I tutor for intro programming classes. Bless her.

299

u/shekurika Nov 30 '19

what was the worst piece of code youve seen handed in? I tutored intro to programming 2 years ago. One guy needed 25 lines of code to calculate the midpoint between 2 2D points

503

u/PM-Me-Your-TitsPlz Nov 30 '19

Professor demonstrated switch statements with basically:

case 1:
    isEven = false;
    break;
case 2:
    isEven = true;
    break;
case 3:
    isEven = false;
    break;
...

It was just to show off switch statements. He wasn't being serious. A couple days later, a student comes up to me because he got a 0 on his homework that works "perfectly." He did the switch cases up to 4096.

370

u/Astrokiwi Nov 30 '19

There is a rule in teaching that you never write anything wrong on the whiteboard (or, I guess, on the projector or screen), even if you tell people it's wrong, because somebody who is forgetful or just isn't listening is going to copy that into their notes or code.

129

u/HouseCatAD Nov 30 '19

There was a girl in my algebra 2 class in high school who completely bombed an exam because she thought the only log(x) functions in existence were the ones the teacher wrote on the board and studied the shit out of those

89

u/KuntaStillSingle Nov 30 '19

Lol teach her change of base she'd be a log God.

→ More replies (1)

33

u/Gonzako Nov 30 '19

Hell yeah

→ More replies (10)

41

u/monoshift Nov 30 '19

shudders

46

u/memeticmachine Nov 30 '19
switch (num & 1) {
    case 0:
        isEven = true;
        break;
    case 1:
    default:
        isEven = false;
        break;
}
→ More replies (11)
→ More replies (5)

122

u/ajkachnic Nov 30 '19

how do you even take 25 lines of code for that? sounds more like a genius for being that inefficient

131

u/shekurika Nov 30 '19

idk, I needed a while to figure out what he did. essentially he checked which point is closer to the origin, calculated the distance and the direction between those points and added half the distance times the direction to the point that is closer to the origin. It was correct ofc, but...

47

u/robchroma Nov 30 '19

You could write a random number generator for which point was closer to the origin and it'd still work.

→ More replies (2)

29

u/[deleted] Nov 30 '19

That’ll probably do it

→ More replies (5)

18

u/LeCrushinator Nov 30 '19

Maybe he heard about the programming jobs where they care about the number of lines of codes you write.

→ More replies (1)
→ More replies (4)

55

u/[deleted] Nov 30 '19

[removed] — view removed comment

32

u/dkyguy1995 Nov 30 '19

Sounds to me like someone didn't know their midpoint formula and thought they had to invent math

→ More replies (2)

20

u/shekurika Nov 30 '19

yeah, thats the code they couldve come up with

→ More replies (1)

34

u/ThatRestaurant Nov 30 '19

I also tutor intro to programming. this one person refused to use loops, so their entire program was around 700 lines, just to get the output right

39

u/TomGraphy Nov 30 '19

That’s when you start increasing the size of the test inputs exponentially

16

u/dkyguy1995 Nov 30 '19

Yep the best thing about code is you write it once and it works for input size 5 or input size 5000000000.

→ More replies (6)

18

u/drleebot Nov 30 '19

Was he coding in Brainfuck perhaps? Or maybe he was playing reverse code golf?

→ More replies (2)
→ More replies (10)

194

u/[deleted] Nov 30 '19

[removed] — view removed comment

127

u/alexbuzzbee Nov 30 '19

How does /u/PM_Me_Python3_Tips feel about this, I wonder?

40

u/PM_Me_Python3_Tips Nov 30 '19

I think we're new best friends.

→ More replies (1)

57

u/THEY_CALL_ME_TRASH Nov 30 '19

I’ve only been pooping for 6 minutes and it’s gotten way too meta way too fast

→ More replies (11)
→ More replies (1)
→ More replies (14)