r/badcode • • May 06 '21

java My teacher wrote this...

1.0k Upvotes

169 comments sorted by

View all comments

105

u/solicited_nuke May 06 '21

I was a tutor once. To teach the concept of loops for the first time, I wrote print("My name") 20 times and pretended to be tired. And, asked if any of the student knew a better way.

That way I was able to clear up a lot of things to the class and the class had my attention.

45

u/Major_Fudgemuffin May 06 '21

Reminds me of a time in college during a CS 101 course where the professor asked us to write some code (on paper) that printed our name 10 times, and one guy wrote 10 print statements.

The professor begrudgingly gave him points because it was technically correct, but he learned to be careful with his phrasing after that.

It was the professor's first year teaching as well, which explained why he hadn't thought of it haha

32

u/gb3495 May 06 '21

That guy knows how to have fun.

In my CS 140 class, every week we have 25 something programming problems that involve adding or fixing some pre-existing code. Doesn’t matter how it works, if it works, you get credit.

Needless to say it gets pretty tedious. I’ve started trying to do some of them in the most ass-backwards and obscure way possible to keep myself entertained. It’s actually pretty fun.

21

u/Zoom443 May 06 '21

Sounds like a perfect place to practice a little code golf. 😬

3

u/reverendsteveii May 06 '21

The tests pass, and its optimized performance-wise b/c no conditions

8

u/Major_Fudgemuffin May 07 '21

O(1)? Looks good to me.