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
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.
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.
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
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...
I get what you're saying here with that being more complicated than necessary, but I think that that's a good thing. It's easy to learn the "right" way to solve sanitized problems, but it's hard to learn how to come up with a solution when you don't know the "right" way (if it even exists). I think that, for the most part, you either have it or you don't, and it sounds like that student has it.
Brainfuck is an esoteric programming language created in 1993 by Urban Müller, and is notable for its extreme minimalism.
The language consists of only eight simple commands and an instruction pointer. While it is fully Turing complete, it is not intended for practical use, but to challenge and amuse programmers. Brainfuck simply requires one to break commands into microscopic steps.
I once did an entire project for a class in a single line of python code. The teacher said I couldn't one-line the program though, so I wrote 80 lines of code and all they did was take the input and call a function containing the one line.
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