The Fastest FizzBuzz in the West
promptworks.com
promptworks.com
In all seriousness: this is a really cool article, thanks for sharing! I'm not very familiar with RPython or RPLY and it was really cool to see a "real-world" example of it. I actually just read through something similar in JavaScript (https://github.com/thejameskyle/the-super-tiny-compiler). I really should give language implementation a shot one of these days (closest I've come is writing a JSON lexer & parser); always like to read about it!
https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_...
Nah, those articles tend to fizz out
Jeff Atwood on the other hand thinks it's a great way to filter out "developers" who can't program their way out of a wet paper bag:
The side of hiring I find interesting is more on the behavioral side - many employers don't find enough ways to screen candidates on those grounds, and it is interesting the ways you find candidates filtering themselves out there if you ask the right questions.
One young person showed up with a resume listing about 10 programming languages. I simply went through the 10 and asked her how to write a comment for each language. We didn't have to go far before she admitted that she really only knew Pascal very well.
To be fair, there were a lot of people that would have made good employees be didn't happen to quite fit the job we were trying to fill at the moment. The matching process often involved a significant degree of luck and I sure that I missed out on many people I should have hired.
> The goal is to sufficiently intimidate junior developers so they will know to steer clear of your organization.
We use fizzbuzz on senior devs claiming to be C++ experts and they stumble on it regularly.
I'm regularly intimidated by positions looking for capital s Senior C++ developers, because no matter how deep my knowledge goes, memory model, templates substitution rules and all, I realize there's dragons lurking behind every corner. Now, C is a language that fits in my head, C++ … not so much, but maybe that's because it is not part of my daily routine.
I'd suggest you look for _productive C++ developers_ that know their limitations. I think you might even get better candidates that way.
It sounds like they are. The "expert" is a self described one.
They were just way too good at playing the game and it took us way too long to get rid of the person - fired, not just dumped.
This outcome can be evidence of either condition:
1. There are a lot of expert developers who are actually not experts
2. The test is giving false negatives
Which do you think it is?
"No programming test these days is valid without full access to Google."
This is the opposite to conventional wisdom which says that programming tests must be done in an isolated environment without access to the web "please deposit your mobile phone at the testing room door".
No programming is done in isolation so the only way to effectively and realistically test someone is to see what results they get in a real world environment, which means full web access.
Don't get me wrong - I am very much against the idea that "I don't need to understand fundamentals cause I can Google everything" - only the misguided think that. What I do think is that recruiting needs to be about measuring real world results - that means full access to Google and StackOverflow.
THE most critical skill that is almost NEVER meaured - and in fact is generally avoided measuring - is the programmers skills in Googling to solve unfamiliar problems. The best programmers ride Google and StackOverflow like racehorse jockeys ride the ponies.
It forces the employer to create a test that is more real world and thus is a closer reflection of the actual work being done at that company.
Unless of course your company is doing alot of real world fizzbuzz.
There is plenty of room for more open tests, but fizzbuzz doesn't require it.
That's precisely my point.
If your selection process includes fizzbuzz then your selection process is ineffective.
Both of those examples have rigorous training requirements before it's even legal to call yourself one and even then they still have some level of fraud.
Anyone can call themselves a programmer and the only real world requirement is being able to program.
There are many, many approaches that will also filter them out, but the point of fizzbuzz is to do it immediately without wasting a lot of time of your engineers on candidates that can and should be discarded within five minutes.
Thats the job though. Most jobs include a lot of googling + copy/paste.
FizzBuzz is not designed as a test of real-world programming skills; rather, it is a deliberately easy test to ensure that a candidate can solve an elementary programming problem from scratch.
The idea being, that somebody that can not solve a trivial problem is in no shape to tackle a harder problem.
Many companies overthink this. They add TDD, or try and test if a candidate can implement Dijkstra's Shortest-Path Algorithm, or any number of other complications.
But that all misses the point of what FizzBuzz does.
FizzBuzz is a first-stage filter, and exists only to screen out copy-pasta programmers that, while their resumes might look good on paper, can't actually code.
There are a lot of those programmers out there, even today.
FizzBuzz should take a candidate no more than five minutes in a language they are familiar with. It really should be that level of simple.
After FizzBuzz is when you can dive into the real-world problems, because the candidate has demonstrated that they can write code.
Now, admittedly, I have moved past FizzBuzz, and now prefer doing a simple pairing exercise over-the-phone, but FizzBuzz is still a useful tool in the interviewing toolbox for companies that don't use pair programming.
If you do use FizzBuzz, I do recommend changing it up. Don't just copy Atwood's FizzBuzz problem. Change the numbers, mix the conditionals around, that sort of thing. But keep it just as simple.
I said recently in another thread that the lead tech at my company was complaining during one round of interviews for a senior position, that some of the candidates couldn't even conceptually 'get' FizzBuzz, let alone code it.
> FizzBuzz should take a candidate no more than five minutes in a language they are familiar with
I'll go a step further and say that if you're the kind of person that takes FizzBuzz as a personal insult, then you should be able to write it out in 60 seconds max, and move on with the interview. FizzBuzz is not for 'you', it's for the people who claim to be as good as 'you', so take it easy and move on.
Complaining about FizzBuzz is like complaining about having a police check done, even though you don't have a criminal record. The check isn't for 'you', the innocent person.
I see your step, and raise you. :)
Asking a developer to spend five minutes to write a trivial problem is not an insult. Somebody that takes this as such is probably not going to be the type of person I, or my team, will want to work with, and we can end the interview process there.
I can totally understand balking at a one-day "homework problem" given out as part of the interview.
Not because this is an insult, but because it gives nothing to the candidate. An on-site or remote "test drive" where they spend a day working with the team is fine in my book, because that experience is valuable to the candidate in answering the question of "will I be happy and productive here?"
A company that demands a full- or half-day of time in exchange for nothing, not even information, probably does not value its employees much.
My personal policy is that the interview process can consume no more than one day of a candidate's time in total, plus an hour for a phone screen, and that at the end of the interview, both parties can make an informed decision as to whether or not they want to continue.
But five minutes to complete a trivial programming test? Writing this post took about that amount of time.
My real frustration with FizzBuzz rises from getting this "test" at the in-person interview. Multiple times. Do it in a live coding session as part of the phone screening, and make those results available to all interviewers. Reserve the limited time that is available for in-person interviews for real questions, not filters.
Or think of a better filter question than FizzBuzz. One great example for someone who claims to be a Python programmer - fix this:
def foo(x, bar=[]):
bar.append(x)
return bar
That lets me know that you as the interviewer also know more than FizzBuzz. >>> def foo(a, bar=[]):
... bar.append(a)
... return bar
...
>>> foo('a')
['a']
>>> foo('a')
['a', 'a']
>>> foo('a')
['a', 'a', 'a']
>>> foo('a')
['a', 'a', 'a', 'a']
EDIT: Having the program output as part of the problem would probably help. :DOkay, minus another couple points to me for not testing each case more than once, and yes, if you're going to present syntactically valid code and ask people to "fix" it you should probably state what it's supposed to do, but aside from all that... the hell?
Okay, having Googled the logic behind this behaviour, I still think it's stupid. My next question is - is being aware of little language gotchas like this really so important? It really bugs me that about all I'm good for in the employment market is making computers do stuff, but I'll never pass an "esoteric language behaviour test" in anything - my tastes are too diverse and I've never gone "all-in" on anything. But I don't think it gets in the way too much - you keep your changes modular and test frequently, and if it doesn't work right you figure out why. Which corners of the language you tend to bump into depends very much on your coding style (for instance I try hard not to mutate things which is possibly why I've not hit this before), so even with a brand new language you should be able to get going pretty quickly.
Surely I'm not useless?
Yeah. Python. A fun little wart.
> is being aware of little language gotchas like this really so important
Somewhat ironically, our conversation here highlights why it is important. If you initially tested these three lines of code to your satisfaction and didn't find the bug, how could you assume that your unit tests would catch the bug?
> Surely I'm not useless?
I would hardly think you're useless, but it does show a lack of experience with the Python language. On the other hand, your most recent response also shows a capacity for looking up and identifying the language WTF and how to fix it, skills which are important in lieu of experience.
If you can't define the behavior for such a simple function how are they supposed to know if it's working or not? Several posts later you still haven't. Is foo meant to append to the array? Is it meant to initialize a new one? Is it meant to create one if it's null?
The function is called foo, any normal person would say "wtf is that supposed to do?".
It is a Python gotcha, and nice if you recognise it, but this definitely does NOT give you any indication of whether or not this person is a good programmer.
What can be said is that if someone recognises this isssue then likely they are a good Python programmer. But the converse is not true that all good Python programmers would recognise this, and therefore this is a test that potentially eliminates a bunch of good programmers. That's a bad test.
This test allows the interviewer to feel smug about how much smarter they are than the interviewee. LOTS of interview tests are set up that way. "Oh, you don't know some very specific thing about your primary programming language? Then (jeering) you're not very good are you!! I know that and you don't!". That's not skills evaluation, it's ego wrapped in the guise of skills evaluation.
This is "trick oriented recruiting" and not far removed to me from asking how many ping pong balls would fit in a 747.
When I have asked interviewees to do anything on a whiteboard I've generally said 'pseudo-code is fine or whatever language your comfortable in or even diagram it'. What I'm looking for is an awareness of high-level concepts and ideas. People may not google for something if they don't know to google for it.
Note that I said Fizzbuzz, not an actual in-depth programming question.
FizzBuzz (and similar) questions tell me nothing whatsoever about your programming ability, but they can tell me everything about your lack of it.
In the limited time I want to spend interviewing, an hour on FizzBuzz is a massive waste of everyone's time.
How could it possibly take an hour to write fizzbuzz for anyone of reasonable ability?
If it takes a candidate an hour, something is wrong.
When I experienced FizzBuzz as a candidate I was coding onto a projected screen, and the test involved writing unit tests and doing a final refactoring step into something "reusable". It took the best part of an hour. The instructions themselves required a good 5-10 minutes of reading/parsing to understand exactly what was expected of you.
I agree entirely that it doesn't prove anything about a candidate's likely success as a hire, but it is a reasonably strong signal about their likely failure.
from jobinterviews import fizzbuzz, redblacktree, irrelevanttheoreticaltest
fizzbuzz()
redblacktree()
irrelevanttheoreticaltest() all-1b4059b…-46d74bf1.js:5 Uncaught TypeError: Cannot read property 'length' of null* of 105 print 'buzzfizzfuzz' * of 35 print 'buzzfuzz' * of 21 print 'fuzzfizz' * of 15 print 'fizzbuzz' * of 7 print 'fuzz' * of 5 print 'buzz' * of 3 print 'fizz'
welp
(1..100).each{|n| p "#{'fizz' if n%3==0}#{'buzz' if n%5==0}"}
Fizzbuzz is one of those problems where there's really no clever hidden golfy solution better than the plain old first-reaction naive approach: an iteration with if/elsif/elsif/else.
There are. With a funky calculation.
For example, taken from Rosetta C version:
for (int i=0;++i<101;puts("")) {
char f[] = "FizzBuzz%d";
f[8-i%5&12]=0;
printf (f+(-i%3&4+f[8]/8), i);
}
You might say the calculations are hidden if/else, but well...Edit: Would be nice if the original author of that code snippet threw in some parentheses for a little clarity with the operator precedence.
There is if you exploit that monoid homomorphisms exist from any monoidal type to both the Optional and Function types.
My favourite solution is this:
let (m ~> str) x = str <$ guard (x `mod` m == 0)
in map (fromMaybe . show <*> 3 ~> "fizz" <> 5 ~> "buzz") [1..100]
This is extensible because you can stick as many rules as you want in there, or even factor them out and make it a function (m ~> str) x = str <$ guard (x `mod` m == 0)
fizzbuzz rules = map (fromMaybe . show <*> mconcat rules)
fizzbuzz [3 ~> "fizz", 5 ~> "buzz", 7 ~> "bazz"] [1..100]For me it's not about getting it 100% correct, its about showing that you can do basic programming and know how computers work, followed by the simple breaking down of a concept into a program.
The rest I consider details. Even if you implemented it 100%, its so simple that it doesn't nearly guarantee that you will do the same for a large program. And if you don't get it 100% correct, as long as you roughly indicate some fields where you're going to test for issues I'd be more than happy about it. Thereafter the human factor/generics, for example did it take you 30 minutes to think this up or was it pretty much rapid-fire? How learned of a response is programming to you?
But as to your question; people don't really like being showed up, but that works well for filtering for you as well. If he hated it then it might very well not be a place/person you want to work with.