by _Codemonkeyism · 10y ago · 0 comments
2. I still wonder why around 30% of people with programming experience who have applied to a job when I was recruiting couldn't solve FizzBuzz[1] or string reverse. All of them either University MSc or years of programming experience.
The article hints at using the wrong teaching methods.
[1] Given the written instructions: 'Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.'
I'm asking because if you do a whiteboard test then it's easy enough to get things wrong on both sides of the interview. Humans are just not as accurate as compilers, not even for the simplest of things.
Besides that there's always nerves, misunderstandings, cultural differences etc. In one place I interviewed they asked me to write a factorial method in Java. I assumed they wanted a recursive method, because, factorial, right? Classic recursive example. So I gave them a recursive factorial in Whiteboard Java™. I turned around from the whiteboard to see the interviewers staring at me, their mouths hanging open. And not in a good way. It turns out all they wanted was to see if I could write a simple loop. Instead of marvelling at my amazing recursion powers, they got the impression I was needlessly flashy and probably had my head up my arse. Also, seeing them staring I completely panicked and I totally screwed the iterative version: the loop went up instead of down, I was adding where I should be multiplying... a shambles.
So they didn't hire me.
Shit happens in interviews and it's not because "Johnny can't program". It's because "Johnny can't pass a programmign interview" (or at least many of them).
I tell people they can use the language I hire (Ruby,JS,Java) but I'm fine with other languages or pseudo code.
I tell people I don't care about semicolons or braces, I don't hire them for being a compiler.
Factorial I also use sometimes. Recursive is fine with me if it works, I've seen many people to go the recursive way - hey it's factorial - and then screw up. I sometimes ask people to do an iterative solution, or I ask if the recursion went flawless to write it as tail recursion.
You can definitely step through your program by hand and follow the logic etc, and you should totally be able to do that, but most programmers will not be in the habit of doing this. And neither should they, because it's slow, tedious and error-prone to hand-simulate your algorithms, or even just your for-loops. Not to mention recursive, or larger stuff.
I guess what I'm saying is that programmers are used to "lean on the compiler" and you don't have that on a whiteboard exercise, so it's a bit artificial.
[Full disclosure: I'm in the habit of hand-simming my stuff especially in the last year where I've been developing a grammar induction algorithm, so I'm not worried that I'll have to stand on a whiteboard and not know how to step through a loop, but I still think it's not very useful to make people do that).
What language did you do your high-school level stuff in? I assume it wasn't Java, because in Java there are no good reasons to use recursion (it provides iterative primitives, unlike say Haskell, Prolog, Lisp etc) and there are good reasons not to (its compiler doesn't (or didn't) do tail-call optimisation).
Not to mention, any language without pattern matching is a bit shit for teaching recursion anyway: you tend to miss the point because of all the bookkeeping.
It feels a little like a window to the programmers mind. Some of them are disturbed by the simple repetition and come up with obfuscated or infective solutions etc.
take a world 100m running champion and ask him to run the 30m with making 360 deg rotation left on each 3rd step and rotation 360 deg right on each 5th step... That would be such a fun, like a drunken duck...
A priori you might expect to find that there were lots of candidates who could do string reversal and fizzbuzz but nothing else. This doesn't seem to be the case.
I like the kinds of interviews where you assign a coding problem before the interview and review the code, or where debugging is part of the tech interview.
'Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.'
people should not be able to write the code? Just by hearing the answer 6 to 7 times ("By the end of interviewing 6 or 7 people") someone knows the answer?
"Possibly you, before you put together your list of interview tech questions."
No actually given the instructions I could write the code in one go. So I'm mystified as why someone applying to a developer position could not do this in your opinion.
I find it much more likely that the fizzbuzz failers are the students who wanted to copy my programming projects in undergrad.
I've seen this for people that were hired and proved excellent.
Everyone can do Fizzbuzz or reverse a string on the job. Much less can do it correctly the first time, on a whiteboard, in a job interview. When you hire a carpenter, you don't ask him to hit a nail with a plastic hammer while you watch.
When this happens to me, people in the interview tell me something like "This is easy, are there strings attached I can't see?"
Whatever happened to, "he seem to be able to code, let's try it for a couple weeks"?
Happened to me twice where everything was fine and then after having been interviewed by 5 or more people, one of them has a bad feeling, and you're not given a chance to prove yourself in a probationary period. Situations like that made me wonder if freelancing is a better path.
Even in these circumstances I've had a decent proportion of candidates never able to even begin to outline some code, let alone get far enough in to enounter "tricks" or "pitfalls". These are candidates I'm comfortable assuming have not learned to code.
I code for fun mostly and I feel like even my 'basic' level knowledge should be able to outline code for a simple problem like fizzbuzz or string reversal.
Mind still blown? Yeah, well, it happens more than you think. Varying definitions for "SDET" are out there, but I think most would agree that an SDET should be able to code. I've had SDETs with Microsoft on their resume that couldn't even match curly braces, let alone write something that would compile and work.
So I use FizzBuzz or an equivalent. I tell the candidate up front that it should take them single digit minutes. I offer points for creativity if they find it too simple. And once in a while a candidate with ten years experience shows up who can't do it. Glad we didn't start with that red/black tree implementation, then.
Same here.
'Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.'
It spells out in words what needs to be written in code.
String reverse is: Write a method/function that returns the reverse of it's argument. Would be interested to learn how these are trick questions.
If the solution is fine, I ask were they see problems. Some mention UTF-8/16. I'm happy if someone tells me this is tricky and there is a working solution in library X or they would google for a solution that works with UTF-8/16.
'Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.'
[1] if stuck on modulo I usually suggest to assume there is a function divisible
How can you expect to be a professional software developer if you can't get some specs, then develop a solution?
If someone perceives "FizzBuzz" to be a "trick" question, he's exactly the kind of person FizzBuzz question should weed out as fast as possible.
That being said, I'm assuming the failure mode we're discussing is 'flailing at the whiteboard and would never make any progress given infinite time' and not 'wrote an off-by-one error that a unit test would catch.'
fizz = 3
buzz = 5
both = 15
for i in range(1, 101):
if i == both:
print "FizzBuzz"
both += 15
fizz += 3
buzz += 5
elif i == fizz:
print "Fizz"
fizz += 3
elif i == buzz:
print "Buzz"
buzz += 5
else:
print iThe "trick" is the first hump - a goat.
string reversing in place trick: stopping at the middle else it's an identity function.
Any time you spend with Fizzbuzz, you could spend it on more complete quizzes, discussing past experiences, taking references etc.
When I asked these kinds of questions I would execute the program in my head, and tell the candidate things like "your reverse() methods moves some stuff around, but the end result appears the same as before". Or "this fails with ArrayIndexOutOfBounds on line X". Typically it only took a few minutes to find the bug and fix it, and I learned about how the candidate solves problems.
Programming is all about abstraction. And fizzbuzz is an abstraction of a huge range of programming work.
Namely:
go through this data
pull out bits, based on these conditions
then do something with it
Some version of that underlies the vast majority of programming work.
They are the exact opposite. They are practical, very simple, introductory questions. Fizzbuzz is literally "do you know what a loop and a conditional are?".
On the one hand, I'm tempted to say everyone should be able to do that, on the other hand, they do feel like a type of programming that isn't super common in a lot of applications. FizzBuzz is probably a bit better in that regard.