3 ms·
I'm not a programmer, and had never heard of the fizzbuzz question. After seeing so many people come out in favor of it in the comments, I looked it up. It is j
by skuhn 12y ago
I'm not a programmer, and had never heard of the fizzbuzz question. After seeing so many people come out in favor of it in the comments, I looked it up. It is just so easy that I have to imagine people who "bomb" it are failing because they're expecting a difficult question and wind up overthinking it.
I mean seriously, this is the question as I found it:
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
And here is an answer in bash that took me literally 30 seconds:
for num in {1..100} ; do
out=""
(( $num % 3 == 0 )) && out="Fizz"
(( $num % 5 == 0 )) && out="${out}Buzz"
echo ${out:-$num}
done
If this somehow provides valuable insight into a candidate, it certainly shouldn't be occupying prime 'in person' interview time. Request it before you schedule the on-site interview. Even identifying as a non-programmer, I have been asked much harder programming questions in interviews.
- jlebar 12y agoI've never asked fizzbuzz, but I have asked people to count the number of upper-case letters in a c-string. I feel like this is of similar difficulty, for people who claim to know C/C++. When I asked that question, I was looking for fluency. A candidate shouldn't have to think about it. They should write c >= 'A', instead of floundering because they don't remember the ASCII value of 'A'. If asked, they should be able to iterate over the string without taking strlen first. This is basic stuff, but you might be surprised how many people with years of software development experience on their resumes can't do it. Moreover, I found that a good performance on this easy question was highly predictive of good performance on harder questions. Not that this didn't stop me from asking hard questions. :)
- deleted 12y ago[deleted]
- Gurkenmaster 12y agoUnrelated: In Unicode that would be a pretty difficult problem. The uppercase version of 'ß' is actually two characters "SS". There are a lot of messed up casing rules in the unicode standard. http://unicode.org/faq/casemap_charprop.html#11 http://unicode.org/faq/casemap_charprop.html#11
- scatters 12y agoSure, casing is complicated; but determining whether a codepoint has the uppercase property is easy - just use u_isUUppercase(). Where it does get complicated is determining whether a codepoint or a digraph of multiple codepoints is a letter, and that's culture-dependent; e.g. IJ in Dutch.
- S4M 12y agoIMHO this kind of questions is asked not to determine if the candidate is good, but if he's bad. Indeed, only someone who is really bad at programming would fail it - modulo small syntax errors due to writing code on paper or white board. If the person fails, you should try to show him politely the door - or better, FizzBuzz should be used in phone screen. However, if the person succeeds, it's pointless to ask him or her a more sophisticated version of it, instead, you can ask more complicated questions (algorithms or architecture), and I think that is what RayVR is pointing: it's ok to ask FizzBuzz once, but don't waste the interviewee time asking it 50 times.
- skuhn 12y agoAs you say, in a phone screen might be suitable place for it. And I certainly don't think there's any point in iterating on it, the only real optimization available is to eliminate the third check for 3 and 5 simultaneously. Truly rocket science. My main problem is that, as a candidate, I would interpret being asked this question to mean that the interviewers have already undervalued me (or worse, have no idea how to value me). One weak question in hours of interviews isn't bad, but now I'm mentally preparing for more weak questions. Making a candidate disengage is a sure way to get a bad interview, or a good interview that results in a "no thanks" to your offer.
- mseebach 12y ago> My main problem is that, as a candidate, I would interpret being asked this question to mean that the interviewers have already undervalued me (or worse, have no idea how to value me). No, your main problem is just how many of your contemporaries with indistinguishable backgrounds and experience totally bombs this question. Being offended by a simple fizz-buzz style question[1] is roughly as constructive as being offended by "Is this a good time to talk?" even when a good time to talk has been carefully scheduled. 1: I don't think many people use fizz-buzz exactly, it's too well known, but there are tons of other really quite simple questions that exercise two or three basic programming concepts, maybe throw in some basic problem solving for good measure.
- DanBC 12y ago
- reledi 12y agoIf you can write a FizzBuzz solution in bash in 30 seconds, you are definitely a programmer. You don't have to program as a profession to be a programmer.
- skuhn 12y agoI mentioned that I'm not a programmer because that's typically the biggest hurdle for me in technical interviews. I don't write code for a living, nor do I want to. Yet I still get asked programming questions, but nothing remotely this simple.