FizzBuzz

Apr 26, 2013 12:33

So I'm sort of looking for a job, not that my startup isn't fun and all, but cash flow is kind of a problem. So I was sent this programming test ( Read more... )

Leave a comment

Comments 4

cdk April 26 2013, 17:51:53 UTC
I wonder if they would have accepted a link to Rosetta Code.

Reply


mmcirvin April 26 2013, 20:06:00 UTC
This is a classic interview-type exercise to see whether you're competent enough to write something absurdly simple but just nontrivial enough to trip up the stupid.

But it always drops me into morbid speculation about what is the best way because oh my God they're watching my every move. Treat the "Fizz", "Buzz" and "FizzBuzz" cases separately? That involves redundant checks! But putting them together means using some kind of flag to remember whether to print the integer! What if this guy is one of those people who says if you ever use a boolean flag you should refactor the code? WHAT THEN??

Reply

haineux April 26 2013, 23:34:56 UTC
"I understand you would prefer to write it another way. I would have tended to agree with you, back in the Eighties."

Reply

mmcirvin April 27 2013, 00:17:53 UTC
One of the Java examples on Rosetta Code uses string concatenation, and checks the string for non-null contents. But strings are immutable in Java, so... object churn???!

(Of course all of this worry is absurd premature optimization; with a code snippet like this you should probably write whatever looks simplest to you.)

Reply


Leave a comment

Up