FizzBuzz: the test helps filter out the 99.5% of programming job candidates
c2.com
c2.com
Why the this story, just if you give anyone a choice of any language to solve fizzbuzz or other problem, be sure you are open to see code that looks strange to you.
https://www.goodreads.com/quotes/540355-he-walked-straight-o...
The beauty of FizzBuzz is that while it's obvious it can lead to interesting places. If a candidate just knows a way or two to implement it they'll quickly run out of things to say when you're talking about their solution. Discussing a solution and improving it is a skill you want in a developer. FizzBuzz can discover how competent they are at that. The way I use FizzBuzz isn't really about finding out if someone can code. It's about something bigger than that.
print '\n'.join(("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else "") or str(x) for x in range(1, 100))
or even: from __future__ import print_function
map(print, (("fizz" if x % 3 == 0 else "") + ("buzz" if x % 5 == 0 else "") or str(x) for x in range(1, 100)))
What if they come up with a solution, you have no idea why it works, but it works ?Sadly, I expect most interviewers would react very negatively. I've already learned never to demonstrate actual programming ability, even when asked. Instead, answer every question the way you would answer physics problems in high school. You know, the problems asked by the teacher who has a bachelor in biology.
People are even justifying this with "clean code" arguments and the like. "Why aren't you using the framework ?". "Is that the best way to write such a complex thing". Worst of all : "what does that mean ?". You don't want to be asked those questions, it will not end well.
Interviewers who can't program will then start arguments about how programs should be designed/written, and the answer boils down to "design by committee, manned 90% by people who cannot pass FizzBuzz". Of course, best to leave out the second part if you point this out and instead add "ask for feedback".
And they wonder why development projects fail.
for (int i = 1; i <= 100; ++i) {
boolean pureNumba = true;
if (i % 3 == 0) {
System.out.print("Fizz");
pureNumba = false;
}
if (i % 5 == 0) {
System.out.print("Buzz");
pureNumba = false;
}
if (pureNumba) {
System.out.print(i);
}
System.out.println();
} if (i % 3 != 0 && i % 5 != 0)
this extra boolean variable out? for (var i = 1 ; i <= 100; i++) {
console.log(
_.chain(["Fizz", "Buzz"])
.zip(_.map([3, 5], function(n) { return i%n;}))
.where({"1": 0})
.pluck(0)
.value().join("")
|| i);
} _.each(_.range(1, 100), function (i) {
console.log(
_.chain(["Fizz", "Buzz"])
.zip(_.map([3, 5], function(n) { return i%n;}))
.where({"1": 0})
.pluck(0)
.value().join("")
|| i);
});"[FizzBuzz helps to] filter out the 99.5% of programming job candidates who can't seem to program their way out of a wet paper bag."
He's not saying 99.5% of candidates can't do it, but rather 99.5% of candidates who can't seem to program their way out of a wet paper bag can't do it. Presumably 1 in 200 of the candidates who can't program manage it by blind luck.
The title here on HN is wrong too.
when he said "print every number up to one hundred and if its the 3rd line print fizz and if its the fifth line print buzz"... honestly my train of thought was "why the fk would u print every line and print again if its the 3rd line and print again if its the fifth line...?? and why would you print 6-100?"... not the best explanation either, and i had no idea he meant print the string "Fizz" when he said print fizz... i thought maybe he meant some ruby gem rails.Fizz or what not...
of course the commenters code example above is clear as day, maybe i just read code better than i talk about code (this so much... for a lot of us). and i didnt get that job.
The job of the person that gets interviewed is to weed out the places where you do not do anything interesting intellectually.
Sure, ask this question, but you'll ask quite a lot from your applicant to still consider your company an interesting place to work for.
Isn't that harder than the actual question?
def is_prime(x):
if x%3 and x%2:
return True
else:
return False
print is_prime(4)
print is_prime(7)
EDIT: Oops, nevermind... you're all right and I'm wrong. I'm not fixing this code so everyone can see exactly how I screwed up.Edit: Perhaps you should keep this in mind next time you declare 99% of programmers incompetent because they made a typo when you asked them to write code down with pencil and paper in a high pressure interview situation.
It's amazing how much doing a few interviews inflates people egos.
"What's the first (positive) number my function will have wrong?"
Am I missing something, or is that basically what you're looking for?
So... actually, I don't know if it's filtering anything really. It's just interesting to watch people do it and it at least establishes that the candidate isn't a complete faker.
Best programming test I've seen was one that was done online, and automatically ran your test through unit tests.
Doing a test is fine, but do it, don't waste my time and move on accordingly to the result. Also, make me do it first, so the technical ability is off the table at an interview, don't make me 1) do it "on paper", (or like a quiz show) and in your location and 2) rate on objective measures (like passing/failing some test) and be transparent about scores (like they would be in a code review)
I agree with being transparent about the discussion around the result of any programming done during an interview but having the person do it before hand defeats the purpose of using it to catch out people who can't actually code because they will just Google the result.
Then don't use FizzBuzz. It's that simple
FizzBuzz irritates me because they haven't gone to the trouble of thinking something else.
Another thing I was given was "make me something interesting in 30min" or "try to solve this problem in 2 hours"
>FizzBuzz irritates me because they haven't gone to the trouble of thinking something else.
Because they don't have to. It's simple and easy to use filter that will remove a lot of noise. It's not perfect, some people will memorize a solution to it but simple changes to the question solve that. But it does really work.
I think having to sit on the other side of the table for a while gave me a lot more respect for the pain that is being an interviewer.
>Another thing I was given was "make me something interesting in 30min" or "try to solve this problem in 2 hours"
Which are totally different and often useless beasts though done right really helpful but honestly I was never willing to invest 2 hours into a single interview nor make someone sit in a room for 2 hours while I went back to work.
But I understand that FizzBuzz gives you a high degree of confidence that the candidate can work in the given language.
"I was never willing to invest 2 hours into a single interview"
Well, lucky for you, at my last unemployment stint this was a given (but not with one single interviewer). However, the 2h test was "offline"
["Fizz" if isinstance(x,int) and x%3==0 else x for x in ["Buzz" if isinstance(x,int) and x%5==0 else x for x in ["FizzBuzz" if x%3==0 and x%5==0 else x for x in l]]]
I'm using a triple check, I'll find a better solution with just two check.
['FizzBuzz' if x % 15 == 0
else 'Fizz' if x % 3 == 0
else 'Buzz' if x % 5 == 0
else x for x in range(100) if type(x) is int]Do it yourself first, so that you have interesting questions to ask; and you can keep iterating on it too. Get them to write tests for it, documentation, what are the error conditions, how do they want to do error processing, and so on.
<?php
for ($i=1;$i<=100;$i++) {
if ( ($i%3===0) AND ($i%5===0) ) {
echo "FizzBuzz\n";
} else if ($i%3===0) {
echo "Fizz\n";
} else if ($i%5===0) {
echo "Buzz\n";
} else {
echo $i."\n";
}
}
?>