FizzBuzz
Hmmm...
In Bash, I would have done:
Then again, it took me about 10 minutes to do that. (I couldn't get the ternary operator to work, somehow.) In C: about five minutes (rusty -- I last used C way back in college {ages ago!}).
In a recent phone interview, I was asked to programmatically (in shell) rename a set of files. I blundered for about two minutes, and gave up in the end, saying I could probably do that by experimentation. I could fairly say I passed that interview. The point? Answering "FizzBuzz" questions does not reflect real-world situations -- it's how you approached the problem, even if you didn't get the answer, that matters.
If I were an interviewer, I'd concentrate on the steps rather than the solution.
In Bash, I would have done:
$ for i in `seq 100` ; do if [ `expr $i % 15` -eq 0 ] ; then echo FizzBuzz; elif [ `expr $i % 3` -eq 0 ]; then echo Fizz; elif [ `expr $i % 5` -eq 0 ]; then echo Buzz; else echo $i; fi; doneThen again, it took me about 10 minutes to do that. (I couldn't get the ternary operator to work, somehow.) In C: about five minutes (rusty -- I last used C way back in college {ages ago!}).
In a recent phone interview, I was asked to programmatically (in shell) rename a set of files. I blundered for about two minutes, and gave up in the end, saying I could probably do that by experimentation. I could fairly say I passed that interview. The point? Answering "FizzBuzz" questions does not reflect real-world situations -- it's how you approached the problem, even if you didn't get the answer, that matters.
If I were an interviewer, I'd concentrate on the steps rather than the solution.
Comments
Post a Comment