News for hackers. Stuff that matters.
Re:FizzBuzz Still Works by Deestan on Thursday November 15, 2012 @10:35AM (#4788977)
> 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.

Re:FizzBuzz Still Works by marknutter on Thursday November 15, 2012 @10:40AM (#4788999)
Emphasis 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.
Re:FizzBuzz Still Works by ssebro on Thursday November 15, 2012 @11:38AM (#4789337)
I have to agree with this one. It sounds absolutely crazy that the average engineer can't write fizzbuzz during an interview.

But if you take a second and think about it, how the hell could these same people who fail fizzbuzz write production code in previous companies? Are you really saying that you believe that fizzbuzz is more complicated/difficult than their previous work?

As someone who's run lab experiments and who's seen a bunch of surprising results, trust me when I say that shocking results usually mean that you're running a test that you don't understand.

In this case, you're probably testing for a host of things that have nothing to do with day-to-day engineer performance.

Re:FizzBuzz Still Works by Nursie on Thursday November 15, 2012 @11:48AM (#4789395)
"how the hell could these same people who fail fizzbuzz write production code in previous companies?"

Maybe they had a lot of supervision, or were someone that could talk a good game to management but didn't deliver, or maybe they just fiddled around with minor stuff in other folks' code.

While experience is obviously a really good thing and a useful thing, if they can't write fizzbuzz you'd have to re-evaluate that experience in the light of new knowledge.

Re:FizzBuzz Still Works by ssebro on Thursday November 15, 2012 @12:09PM (#4789538)
I think you missed my point. I'm saying that fizzbuzz is very, very unlikely to be something you should use for evaluating someone's experience.

What I'm pointing out is a fundamental problem with coding problems.

FizzBuzz is a relatively simple problem to solve, so if fizzbuzz fails as a test for coding ability, then it's fairly likely that all coding problems fail.

There's are probably better metrics (faster, more uniform, etc) that you could use to figure out how good a coder is.

For example, one thing I've noticed is that I'm fairly aware of the skill levels of everyone I've ever worked with. I think it might be interesting to see how peers rate each other (A players can tell A players, and so on)- maybe that would be the metric that's most useful. All I know is that FizzBuzz probably isn't it.

One last thing I need to add: the people who are dramatically more productive coders are not always dramatically more productive because they code faster or better. It's often because they enact/enable processes that amplify the other developers. (e.g. the developer who pushes the company to have a hackathon, or the dev who creates machine images preconfigured for deploying test and dev builds).

Re:FizzBuzz Still Works by Nursie on Thursday November 15, 2012 @01:01PM (#4789828)
This isn't about a metric of how good a coder is though, it's an absolute minimum, it's a bar to pass, it's a lowest-common-denominator filtering mechanism - can you solve a trivial problem in a generous amount of time?
Re:FizzBuzz Still Works by henrikschroder on Thursday November 15, 2012 @01:22PM (#4789932)
> It sounds absolutely crazy that the average engineer can't write fizzbuzz during an interview.

No no, not the average engineer, the average applicant. Huge difference.

Re:FizzBuzz Still Works by meritt on Thursday November 15, 2012 @11:00AM (#4789107)
Obviously 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.
Re:FizzBuzz Still Works by UnoriginalGuy on Thursday November 15, 2012 @11:37AM (#4789329)
FizzBuzz seems to get a lot of people simply because they aren't familiar with the remainder (Modulo) operator.

I have to admit that I myself rarely need to use it. When I first read about FizzBuzz I tried to solve it by division and then comparing the floating point result to a rounded int result (i.e. circular way to get the remainder).

I'd be interested to see how many people pass if you simply remove the remainder operator part of it entirely. My guess is that near 100%.

FizzBuzz is still less "unfair" than a lot of the trick programming questions, riddles, or random CompSci trivia that many companies (Google, Microsoft, etc) do.

This is one of the reasons I would never even apply at a Google. I don't perform well programming wise under that level of pressure and my "random trivia" reserves are low.

Re:FizzBuzz Still Works by jstelly on Friday November 16, 2012 @05:52PM (#4796296)
It really depends on the type of programming job you are interviewing for, but for all of the jobs I've had I'd expect a candidate to be able to do this with or without using a mod operator. I've asked people similarly simple programming problems; I like the approach. I don't like requiring leaps of intuition or analysis as a filter like this though. So problems should be straightforward. You are checking for fundamental coding and problem solving in an interview like this.
Re:FizzBuzz Still Works by rasur on Thursday November 15, 2012 @11:17AM (#4789218)
Never under-estimate the ability of a stressful situation to completely decimate your ability to perform as hoped, regardless of programming ability.
Re:FizzBuzz Still Works by bmj on Thursday November 15, 2012 @11:31AM (#4789299)
So, when production is down, and clients are calling, and revenue is lost, it's okay to say "I'm too stressed to fix this bug?"

I'm sympathetic to complaints about overly technical interviews (I've bombed a few in my day because of stress and/or ignorance), but as others have pointed out, this is FizzBuzz. I'm generally very bad at interview/algorithm puzzles, but I could even figure this one out pretty quickly.

Re:FizzBuzz Still Works by ssebro on Thursday November 15, 2012 @11:42AM (#4789366)
A better metaphor would be those things happening and your boss saying "solve fizzbuzz in 10 minutes or we'll fire you". (or we'll fire you == not getting the job/failing the interview).

The big difference between the two metaphors is that mine has direct impact on your personal life and negative consequences are gonna be seen as your fault, while yours is a company threat - fixing it will get you seen as a hero, not a disgraced villain.

Re:FizzBuzz Still Works by Nursie on Thursday November 15, 2012 @11:22AM (#4789250)
If you're so stressed you can't write fizzbuzz in an interview then how are you going to deal with any workplace stress?
Re:FizzBuzz Still Works by rasur on Thursday November 15, 2012 @11:29AM (#4789293)
Interview 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.
Re:FizzBuzz Still Works by jlgreco on Thursday November 15, 2012 @11:34AM (#4789319)
How 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?
Re:FizzBuzz Still Works by UnoriginalGuy on Thursday November 15, 2012 @11:43AM (#4789371)
Give them a unique programming problem before hand and ask them to bring their solution to the interview, and then discuss the solution with them.

Unless they "cheat" this should give you a good idea of what they're capable of. The cheating should also show up if they cannot explain it or why they wrote it the way they did.

Re:FizzBuzz Still Works by jlgreco on Thursday November 15, 2012 @12:04PM (#4789495)
How far beforehand would you suggest? Would walking into the interview, handing them the problem, and then telling them that you'll come back in 10/15 minutes to "start" the interview be acceptable?
Re:FizzBuzz Still Works by davorak on Thursday November 15, 2012 @02:23PM (#4790273)
Asking someone to solve a problem in the waiting rooms is considerably different then letting them solve the problem in their chosen environment. Probably not as stressful as durring an interview with people watching however.
Re:FizzBuzz Still Works by rasur on Thursday November 15, 2012 @11:56AM (#4789446)
As noted in another reply to this question, get them to bring in a project and explain it.

Additionally, they could spend some time with the team they'd be working in, pairing (or whatever) with other members and really demonstrating their abilities.

It's not really that difficult to get away from the whole "technical question at the interview" problem, and I'd wager that in the long-term it'd be better for all concerned.

Re:FizzBuzz Still Works by jlgreco on Thursday November 15, 2012 @12:03PM (#4789486)
Eh, maybe. Those are fine interviewing techniques, but I am unconvinced that explaining something technical you've done in the past would really be that different (from a stress-induced difficulty standpoint) than FizzBuzz.
Re:FizzBuzz Still Works by Nursie on Thursday November 15, 2012 @12:59PM (#4789815)
That's the whole point of the article/test - there are loads of folks (apparently) who can talk about it but not produce even this simple example when asked to. You probably don't want them.
Re:FizzBuzz Still Works by jlgreco on Thursday November 15, 2012 @01:25PM (#4789943)
Yeah, that was my take-away. Any "talk about what you have done" that gets specific enough should be susceptible to the same stress though; I cannot fathom how that wouldn't be the case.
Re:FizzBuzz Still Works by rasur on Thursday November 15, 2012 @02:27PM (#4790292)
Which is why I wrote the second part: Drag them in for x days, get them to work with existing staff on existing problems. If you have engaged staff, they will weed out the (clue|use)ful and reject the time-wasters.
Re:FizzBuzz Still Works by Nursie on Thursday November 15, 2012 @02:29PM (#4790300)
But that's a very expensive thing to undertake, when you can use FizzBuzz to filter out the timewasters at little to no cost to yourself...
Re:FizzBuzz Still Works by jlgreco on Thursday November 15, 2012 @02:53PM (#4790418)
There is no way I would invest my staff's time in doing that if I hadn't even established that they could fizzbuzz yet.
Re:FizzBuzz Still Works by danielweber on Thursday November 15, 2012 @11:58AM (#4789456)
Fortunately there are plenty of employers.

Even Google lets you try again in a year.

Re:FizzBuzz Still Works by dllthomas on Thursday November 15, 2012 @11:30AM (#4789298)
Reminds 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."
Re:FizzBuzz Still Works by sync on Thursday November 15, 2012 @10:39AM (#4788991)
His 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
Re:FizzBuzz Still Works by raganwald on Thursday November 15, 2012 @10:44AM (#4789019)
That'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.

Re:FizzBuzz Still Works by lucisferre on Thursday November 15, 2012 @11:04AM (#4789132)
Yeah 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.

Re:FizzBuzz Still Works by AccordionGuy on Thursday November 15, 2012 @12:44PM (#4789736)
[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.

Re:FizzBuzz Still Works by fhars on Thursday November 15, 2012 @11:18AM (#4789221)
But 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.

Re:FizzBuzz Still Works by irahul on Thursday November 15, 2012 @11:18AM (#4789226)
edit: 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:)

Re:FizzBuzz Still Works by AgentConundrum on Thursday November 15, 2012 @10:59AM (#4789102)
I'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.

Re:FizzBuzz Still Works by jeltz on Thursday November 15, 2012 @11:14AM (#4789194)
His 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"
Re:FizzBuzz Still Works by reidrac on Thursday November 15, 2012 @10:46AM (#4789034)
Are 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.

Re:FizzBuzz Still Works by DougBTX on Thursday November 15, 2012 @12:06PM (#4789510)
The 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.
Re:FizzBuzz Still Works by wildmXranat on Thursday November 15, 2012 @11:13AM (#4789187)
Well 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.