Hacker News new | ask | show | jobs
by pixeloution 5383 days ago
Just curious if you expect perfect code on a sheet of paper or give them an IDE and say go for it.

As I remember fizzbuzz (print numbers 1 thru x, then fizz if divisible by 3, buzz if divisible by 5, fizzbuzz if divisible by both)

I did it in a text editor in under a minute. Got two errors because I did it without thinking, fixed it, and had a working solution in 90 seconds. It's taking me longer to write this response.

I can't imagine anyone who writes code daily who couldn't get this right in under 5 minutes given a text editor and a way to run the code, but I could imagine plenty of people who trying to do it on a sheet of paper who would make goofs. And most of those would make good employees.

4 comments

I can't imagine anyone who writes code daily who couldn't get this right in under 5 minutes

Yes there are people who apply for programming jobs and do not write code daily, or even cannot code at all. FizzBuzz is designed to quickly identify them and filter them out.

Back in the days when I did this (1990s) we did the C/C++ reverse a linked list and compute the factorial of a number. And, yeah, people made mistakes on a dry erase board under interview pressure, but it was very clear who has a clue vs. who couldn't program their way out of a wet paper bag.

These sorts of tests are low pass filters, they're not designed to find good or great programmers, just confirm that the person can program at all (as we define it). Since most people who call themselves programmers really aren't, they're highly useful. Anyone who's looking for perfection of this nature in an interview and who fails a candidate for lacking that is doing the latter a favor by not hiring them.

Give em a laptop. Those are a dime a dozen (we got a ton sitting around the office). Have em code in front of you. Hell I'd install any interpreter within reason to let em solve it.
It's not about how expensive a laptop is or isn't. If somebody can't master the basic syntax of the language so that they can write a very basic algorithm without syntax errors and in such a way that it would run on the first try, they can't be very productive. And fizzbuzz is really the rock-bottom of the simple algorithms. Even a linked-list library would be a very reasonable thing to ask (if we're talking about C for instance). If somebody has to go through a few edit/(compile)/debug/change cycles for each simple thing, it doesn't sound very productive. Now, obviously if we're talking about an application that involves some baroque frameworks and class hierarchies, things are different, but simple things should be doable on paper.
Writing on a whiteboard while explaining yourself is different from typing alone into an IDE. Conventions you might use to avoid syntax errors (like typing a pair of braces and then filling the middle) may not work on a whiteboard. Pacing is different, and muscle memory doesn't help. You're looking at a blank whiteboard rather than your terminal with other parts of the codebase. The first few minutes of coding are often "getting up to speed"; many programmers are orders of magnitude more productive once they're "in the zone".

In short, I wouldn't consider "your whiteboard code is missing a semicolon" to indicate a lack of productivity overall, only a lack of practice coding on a whiteboard. (It surprised me how much better my whiteboard code got over the course of a quarter of teaching.)

FizzBuzz is not aimed to find the best, the kind of people who fail fizzbuzz don't fail it for syntax errors or semicolons. People fail fizzbuzz by staring blankly at the screen/whiteboard acnd not nothing where to start, you fail fizzbuzz by not knowing how to do a loop. You fail fizzbuzz by nkt knowing how to do an if statement, you fail fizzbuzz by not knowing about modulo arithmetic. Fizzbuzz is designed to get rid of those people.
I have never been in an interview for a job as programmer, to be honest, but really, we're talking about fizzbuzz here. You should be able to recite it in your favourite programming language. :)

For more complicated tasks I guess you can say it's debatable when whiteboard is OK and when you should give the candidate access to a computer.

I have a better grasp of the English language than the average college graduate, but I still make stupid errors even in the comfortable environment of a text editor. I might leave an article out, or I might miss a period, or I might write a homophone even though I know the correct spelling. As an editor, I've worked with a lot of professional writers — to a man, they all made mistakes as well. This is why I proofread anything important.

And that's under ideal conditions! Writing code on a whiteboard is so far from ideal for most people that keeping your variable names consistent is a challenge — balancing parentheses and brackets and keeping track of little dots is outright grueling, and doing all this during a job interview is enough to make even very competent programmers choke.

Amen. Who writes code on paper in real life anyway? The font is wrong, there is no backspace and you can't insert and remove lines. Interviewers have some nerve demanding proper syntax.

Give me a laptop with just a text editor and watch over my shoulder.

I'm not sure if you're sarcastic or not, but would you hire a programmer who can't compute "2+3" in his head? The same argument can be made for basic maths operations: we all have calculators (applications).
There. I wrote it too. 3 minutes, 1 major error in initial impl due to lack of sleep (used / instead of %). 8 lines of ruby. I would be quite surprised if someone could not do this in < 20 lines (of assembly) :P. Damnit now I want to whip out my x86 assembler and muck around.
On paper, and without any syntax errors.

But, to their advantage, they can select any language that they want.