6 ms·
> I can’t go fairly judge other programmers with FizzBuzz without going through the test myself. I implemented it in Ruby, my go-to language for hammering out q
by Deestan 14y ago
> I can’t go fairly judge other programmers with FizzBuzz without going through the test myself. I implemented it in Ruby, my go-to language for hammering out quick solutions, and in the spirit of fairness to those I interviewed, I did it with pen and paper on the first day of the interviews (and confirmed it by entering and running it)
Be careful with this kind of test evaluation:
1. The problem isn't new to you - you have already had the problem in your head for days or even years. Whether you admit it or not, you already have a good idea of how to approach the problem.
2. You are not under stress, as the candidate would be.
- sync 14y agoHis solution isn't even correct, failing his own test. if !multiple_of_3(i) && !multiple_of_5(i) output = i edit: In order to avoid overwriting output, the solution should read... if !multiple_of_3(i) && !multiple_of_5(i) output << i
- deleted 14y ago[deleted]
- raganwald 14y agoThat's probably deliberate: he says himself (and I agree with this approach) that the point is to figure out if someone knows how to program at all. Off by one errors, syntax errors, these are not all that relevant. The failures are the ones who stare at the paper blankly, or have no idea that they need a loop, or some other such hopeless approach. If you get "close enough" on paper and pencil under the pressure of an interview, that's great. You can walk through debugging it if you want to see more, but I wouldn't hold even basic logic errors against someone. I certainly admit that when coding on my own I usually get all kinds of stuff wrong that I fix as I write tests and iterate.
- lucisferre 14y agoYeah I've used FizzBuzz myself, and under interview conditions it's actually much harder to implement a correct (for edge cases, etc.) solution in a short time. I always took that into account. However I also added the twist that I wanted the candidates to also write the tests for the program in TDD style. I hoped that this would actually help, by asking the interviewee to follow a repeatable pattern of first expressing what they wanted to code to do and then implementing. We also did ping-pong pairing so I could help write a test, or do an implementation if things were going poorly, to see if that would jump start the candidates brain into the problem. The results were quite frankly a disaster, no better than what Joey found (though I didn't do enough interviews for a statistical sample). Unfortunately my limited observations have lead me to believe that too many developers (particularly in the enterprise environments) are used to working on legacy codebases that they hack and change until the bug they are fixing goes away. Many rarely implement features much, if at all, and the ones they do are heavily broken.
- AccordionGuy 14y ago[Article author here!] Reg is right. The purpose of the FizzBuzz test was to weed out anyone who couldn't program at all and not punish anyone who forgot a semicolon, used = when they should've used == or some similar error. I was completely prepared to discuss the result if someone got close to a working solution. To my surprise, the candidates' solutions were either bang-on or way off. The guy who asked "Do you think I should use a loop?" had to be cut off at the ten-minute mark, and his paper had only the start of a C-syntax for loop and a lot fo scratched-out lines.
- reidrac 14y agoAre you sure? It looks correct to me. If the number is not multiple of 3 or 5, you must output the number. That's what is he doing. He prints output at the end of each iteration, setting it to empty string at the beginning.
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- AgentConundrum 14y agoI've never touched Ruby, so I could be misunderstanding, but I think his code is correct. In each loop, he initializes the output variable to an empty string. If the current integer is not a multiple, he replaces the empty string with the integer. If it is a multiple, he doesn't know which one it is, or if it's a multiple of both, so he appends the text to the existing string variable. At the end of the loop, the string is output. Since the `output = i` line is the only assignment that occurs when that condition (not a multiple of either) is met, it makes sense to just reassign the variable rather than append to it. It might be less flexible, sure, but flexibility isn't required here.
- jeltz 14y agoHis solutions works while your does not. I ran them both in irb. This is because "string << integer" does not do what you think it does. It treats the integer as character code. "" << 0x41 # => "A"
- fhars 14y agoBut the specification is to print the number, not the character with the character code corresponding to the number. So unlike your "correction", his code does what it should. Admittedly, having a variable that contains either an integer or a string is atrocious programming style, but some people do actually like languages that allow that, so it is par for the course in the given situation.
- irahul 14y agoedit: In order to avoid overwriting output, the solution should read... if !multiple_of_3(i) && !multiple_of_5(i) output << i No. Though output << i.to_s will produce the same result, his code is correct. And yours isn't if you do output << i 1. If not a multiple of 3 or 5 or 15, output = i. 2. If a multiple of 3, output << fizz. 3. If a multiple of 5, output << buzz 4. If a multiple of 15, "fizzbuzz". Already covered in 2 and 3 owing to << Apparently people mess up fizzbuzz even when they know it:)
- DougBTX 14y agoThe line before that is output = "", there will never be any output to overwrite by line output = i. Note that this is output for just one line, not the entire output of the procedure.
- marknutter 14y agoEmphasis on point #2. You're hiring a programmer not a clutch outside shooter for your basketball team. Unless your code consistently has a lot of fires that need to be put out in short order there's no reason to filter people based on clutch performance.
- meritt 14y agoObviously interviews are stressful but this is FizzBuzz we're talking about. If someone cannot figure it out during a moderately-stressful interview, they quite simply aren't a very good programmer.
- rasur 14y agoNever under-estimate the ability of a stressful situation to completely decimate your ability to perform as hoped, regardless of programming ability.
- Nursie 14y agoIf you're so stressed you can't write fizzbuzz in an interview then how are you going to deal with any workplace stress?
- rasur 14y agoInterview stress and normal workday stress are completely different beasts, in my experience. Coping with one is not always an indicator of the ability to deal with the other.
- jlgreco 14y agoHow are we supposed to interview candidates at all, if their interview specific stress is so crippling? What sort of things can they answer, if not at least FizzBuzz?
- 14y ago
- wildmXranat 14y agoWell said. It's equivalent to receiving the exam paper days in advance and bragging how fair or equivalent it is. In fairness to the interviewer, he has the position of the other side and I can't hold it against it him. It's just not the same from the position of the interviewee.
- dllthomas 14y agoReminds me of a test in my intro computer architecture class, where the prof was making the key while we were taking the test, and partway through was like "This is taking me longer than I thought it would, so you guys can take this home and work on it."