Given a 32-bit unsigned integer, return true if the binary representation has two consecutive ones in it.
And...that's it. And people that have passed the recruiter gates and made it through the phone screen just completely lose it here. Let's be clear - I really don't care how you do it. There are 3-4 ways right off the bat ranging from a state machine to a shifting mask all the way down to a single inline math statement.
If you're as comfortable as you say, it will be a no brainer. As a check I took an intern and told him to meet me in a conference room to get the same stress level out of him. I posed the problem and got an answer in five seconds.
Now let me tell you about the candidate that wanted to turn the integer into a character string and then search the string for “11”...
However I understand that may be part of the discussion afterwards.
After years of asking the same questions to intern candidates and to senior+ candidates, interns did consistently better. There are a lot of "experienced" but not very skilled people out there. They exist already inside ompanies too (Principle level checking in hundreds of lines of code with many classes and tests, purportedly to add logging support to something, but the code was ultimately a NOP as it did nothing) but even if it's impossible to put out the tire fire it's best not to contribute to it.
Programming is not sports. I'm not a coding athlete. Maybe it is for some people, but not for me. That's not what the job I've held for all this time has ever been about.
Plus you get to a certain age and experience and the thought of "proving myself" to some 25 year old is just... Really?
If you just don't like hand writing and prefer typing, then that's cool with me and you can just do that during the interview (the content of interview is important, not the medium you write with).
If you're mentoring a 25 year old you'll have to prove yourself to them every day.
No, you won't. If they don't want to listen to you, they don't have to. As a mentor it's my job to listen to them and guide them with experience as my context, not joust with them over irrelevant, stupid, gotcha contests. And I'm happy to help them realize that just by not engaging in it.
Every senior engineer I've worked with including myself is able to write a for loop with a few lines of code in the body, because doing basic coding like this is important when training new grads and doing code review (not to mention when writing your own code).
Not sure if you are trolling.
That's an extraordinarily simple coding problem, and the usual ones you have to pass to get into Google are much harder.
Getting the job @ Google was worth that stress. The original comment I made was to the effect of: before you dump a coding test on me, you better make sure it's worth the stress by convincing me why.
Fizzbuzz wasn't designed to test people's prowess in coding. It was designed as "This is one of the simplest possible programs one can write. Can this candidate do it?" While many people may go through their whole career not dealing with dynamic programming or most data structures, almost all programming is fairly similar to FizzBuzz.
As an analogy, it's like giving someone who claims to be a circuit designer a basic circuit where he's failing at Ohm's Laws or Kirchoff's Theorems. Or an electromagnetics person who cannot integrate a basic polynomial.
If you have test anxiety that's one thing, but if your reason is "I need time to think this through", it's a huge red flag. Kind of like the person saying he needs to consult a table of integrals to integrate x^2.
I'm against intense Facebook/Google style whiteboarding. Fizzbuzz is at the extreme other end of intensity.
But I'd probably want to, just to piss off this person (the throwaway account who came on here to argue...)
Weeellll, I mean it doesn't totally succeed in meeting that design criteria. Fizzbuzz weeds out three kinds of candidates:
- candidates who are (currently) unfit for any programming job
- candidates who freeze up during the interview
- candidates who have never used the mod operator
I fault fizzbuzz a bit, because there are candidates in that last category who have several years of experience successfully duct-taping together libraries to meet product requirements, yet panic because they've never had to find the remainder of division in their language of choice. They might be fine for the rec you have open.A fizzbuzz with fewer false-positive rejections might be something like "implement multiplication without using the multiplication operator".
edit: Oooh! "How many ways can you implement multiplication" would be a much more interesting warm-up/weed-out question! Allows the quality candidates lots of room to shine.
> A fizzbuzz with fewer false-positive rejections might be something like "implement multiplication without using the multiplication operator".
While possibly a fair question, this is a whole order of magnitude more difficult than FizzBuzz. It requires more domain knowledge as well (lots of people have forgotten how to multiply).
> Allows the quality candidates lots of room to shine.
But this is precisely the opposite of FizzBuzz. The goal is to weed out horrible candidates, not identify great ones.
Sorry, in my mind the input was restricted to positive integers. My fault for not making that clear.
def mul(a, b):
accum = 0
while b > 0:
accum = accum + a
b -= 1
return accum
You are correct that accounting for floating point would make this more complicated than fizzbuzz.> But this is precisely the opposite of FizzBuzz. The goal is to weed out horrible candidates, not identify great ones.
This accomplishes both at once. That's a super set, not an opposite.
Granted, that may be counter to the spirit of the question, but it's a valid answer lol
I'll give an easy question, but I'll have them do it ssh'd on to a remote machine. I'm more interested if they know how the environment works and how much coaching they need to navigate around.
I haven't been a professional developer for anywhere near 25 years, but I could write fizzbuzz while blindfolded, on a wet bar napkin after a couple of drinks, in any one of at least half a dozen languages.
If someone asked you to write down the answer to 3+5 would you struggle with that as well? To me, fizzbuzz is barely a set up in terms of complexity.
``` case $input when $input % 3 == 0: “Fizz” when $input % 5 == 0: “Buzz” when ($input % 3 == 0 && $input % 5 == 0): “Fizzbuzz” end ```
It's quite ironic that you had all the time in the world to check your code and the ability to silently walk away when the pressure would've been too high and yet you included 2 obvious bugs in your 'proof' of how easy this is.
Thank you for your time, but I'm afraid you would not be a good match for this position at this moment.