TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

FizzBuzz: the test helps filter out the 99.5% of programming job candidates

40 点作者 waitingkuo超过 10 年前

13 条评论

BSousa超过 10 年前
I was once presented this during an interview which wasn&#x27;t going too well (I decided I didn&#x27;t want to work there after seeing the working conditions of the developers: 60+ developers crammed in a small room with minuscule desks, distributed in rows where people would bump into the chairs whenever they had to get up and move) and they told me that a lot of the candidates couldn&#x27;t solve it and would be an elimination test. They told me I could use any language I wanted, so for kicks I did a simple Haskell version of it (nothing complicated, just a fizzbuzz function mapped over the list). I was told on the spot that I failed and they wouldn&#x27;t continue the interview.<p>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.
评论 #8787609 未加载
onion2k超过 10 年前
I love FizzBuzz. The <i>great</i> thing about it is that it&#x27;s easy to write code that works so candidates can feel happy that they&#x27;ve &#x27;passed&#x27; but flexible enough that people&#x27;s solutions will differ. And that&#x27;s what you want in an interview situation - working code that you can talk to the candidate about. If you question what they&#x27;ve done and the candidate can explain and defend their decisions then you can figure out if they&#x27;ll be able to speak up and contribute to technical discussions, to communicate their ideas and comment on other people&#x27;s solutions. <i>That&#x27;s</i> the sign of a good developer (in my opinion).
评论 #8787698 未加载
ivanche超过 10 年前
I&#x27;m a little bit surprised of &quot;if-else if-else if&quot; mindset in c2.com wiki entry for this. I always thought of FizzBuzz solution without a single else, like this:<p><pre><code> for (int i = 1; i &lt;= 100; ++i) { boolean pureNumba = true; if (i % 3 == 0) { System.out.print(&quot;Fizz&quot;); pureNumba = false; } if (i % 5 == 0) { System.out.print(&quot;Buzz&quot;); pureNumba = false; } if (pureNumba) { System.out.print(i); } System.out.println(); }</code></pre>
评论 #8787753 未加载
评论 #8789815 未加载
adam-a超过 10 年前
Idiomatic underscore.js solution:<p><pre><code> for (var i = 1 ; i &lt;= 100; i++) { console.log( _.chain([&quot;Fizz&quot;, &quot;Buzz&quot;]) .zip(_.map([3, 5], function(n) { return i%n;})) .where({&quot;1&quot;: 0}) .pluck(0) .value().join(&quot;&quot;) || i); }</code></pre>
评论 #8788472 未加载
eneifert超过 10 年前
Just curious where you got the number 99.5%? Approximately how many of the people you interviewed couldn&#x27;t complete it?
评论 #8787556 未加载
评论 #8787558 未加载
MrQuincle超过 10 年前
I had a few interviews just out of university. One place gave me a list of boring questions about C++ regarding inheritance, etc. seems straight from a text book. At the other place they asked questions about the political situation in East-Europe and why design patterns might be detrimental to the quality of code. Regarding the fact that I love AI&#x2F;ML and programming is just a means to me, this wasn&#x27;t a difficult choice.<p>The job of the person that gets interviewed is to weed out the places where you do not do anything interesting intellectually.<p>Sure, ask this question, but you&#x27;ll ask quite a lot from your applicant to still consider your company an interesting place to work for.
smtddr超过 10 年前
This is by far my favorite interview question to give. In case the candidate may have memorized it, I might make a slight alteration. Like count <i>backwards</i> from 102 to 2 and don&#x27;t print anything for prime numbers.
评论 #8787573 未加载
评论 #8787774 未加载
评论 #8787585 未加载
raverbashing超过 10 年前
It also pisses off the 0.5% that know how to program<p>Best programming test I&#x27;ve seen was one that was done online, and automatically ran your test through unit tests.<p>Doing a test is fine, but do it, don&#x27;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&#x27;t make me 1) do it &quot;on paper&quot;, (or like a quiz show) and in your location and 2) rate on objective measures (like passing&#x2F;failing some test) and be transparent about scores (like they would be in a code review)
评论 #8787581 未加载
评论 #8795975 未加载
spdy超过 10 年前
I have to memorize a really obfuscated version of this &quot;test&quot; just in case. Sadly no one can remember the brainfuck version.
评论 #8787574 未加载
lormayna超过 10 年前
This is an example in Python using list comphrension.<p>[&quot;Fizz&quot; if isinstance(x,int) and x%3==0 else x for x in [&quot;Buzz&quot; if isinstance(x,int) and x%5==0 else x for x in [&quot;FizzBuzz&quot; if x%3==0 and x%5==0 else x for x in l]]]<p>I&#x27;m using a triple check, I&#x27;ll find a better solution with just two check.
评论 #8787845 未加载
评论 #8788371 未加载
评论 #8787859 未加载
jalanb超过 10 年前
What I find strange about this test is that it also weeds out 99.5% of candidates who can&#x27;t seem to google for &quot;programming interview&quot; before turning up at one! Amazing how many (3rd year Comp Sci) students have never heard of it.
评论 #8789067 未加载
robinwarren超过 10 年前
This test still seems to be under the radar of a lot of candidates. We&#x27;ll need something else to weed out the surprisingly large amount of candidates who don&#x27;t seem to be able to actually code one day though. Any ideas?
评论 #8787689 未加载
评论 #8787615 未加载
评论 #8787830 未加载
beardo超过 10 年前
<a href="https://gist.github.com/zenry/76b42f464a6430dd8524" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;zenry&#x2F;76b42f464a6430dd8524</a>
评论 #8787675 未加载