A new game
This entry was posted on 5/12/2006 6:23 AM and is filed under Oddity.
Well, we've started a new game at Baylor Computer Science to fill the gap between semesters. The objective of this game is to create the most bizarrely inappropriate and complicated implementations of the function that determines whether or not a number, n, is odd. Of course the text-book implementation is the following:
if ((n%2)==1) return true; else return false;
The inspiration for this was a former student of mine who was asked to supply the above statement on an exam. Instead, he tried to test n against every odd number like this:
if (n==1 n==3 n==5 n==7 ...
He put in the dot dot dot because he didn't feel like writing out "the whole thing." Of course I gave him a zero on the question, and wrote a snyde comment about it. He was very offended by this and complained about me to the chairman of the department, among other things. When I finally got him in my office he explained to me that his answer was basically correct, because even though he didn't write down all the odd numbers, he was on the right track. I tried to explain the concept of infinity to him, but this was just beyond his capability to understand. I'd like to name this contest after him, but being the sort of individual he is, if he ever found out about it he'd definitely sue me.