by johnnyb9 · 4y ago · 0 comments
After a few disappointing responses to better questions, interviewer decides to give a "freebie" and asks for a function that determines whether an integer is odd or even.
Candidate produces something that loops from 0 to the provided integer, incrementing two separate counters, then comparing them at the end.
Interviewer manages to stammer out something like "are you sure there isn't a more efficient way to solve this?"
Guy furrows his brow for a few minutes more, then a light bulb of sorts goes on, and he declares "Of course! ..."
"... I only need one counter!"
Though perhaps, if they were more competent as a programmer, they would skip decimal math altogether and use the ol' bitwise operator trick.