Hacker News new | ask | show | jobs
by jedberg 3684 days ago
This whole thing is making fun of asking fizz-buzz to a senior programmer, but yet I've found it to be one of the best phone screen questions possible.

For someone who is truly a senior programmer, they knock it out in about 30 seconds and we move on. For the ones who pretend to be senior programmers on their resume, it trips them up and I know right away that their resume is either a pack of lies or their previous coworkers were helping them a lot more than they let on.

If I had actually had this person, I would have probably laughed as soon as he did the imports, said, "clearly you think this is a silly question" and then explained why I ask that question. Hopefully we could have moved on from there.

4 comments

It's just a jape, not to be taken seriously, made in the great comic tradition of FizzBuzz Enterprise Edition: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
Joking aside, this example does a great job to show one of my complaints with common (edit: enterprise) Java practices - Where is the logic?
Common enterprise OO problems. It is neither confined to Java nor representative of Java as used outside enterprise development.
> nor representative of Java as used outside enterprise development.

It isn't? I've turned down a couple of sweet gigs, at times when I really needed the comfort of work-group structure and maybe even a pay check, because I assumed that (based on my reading) it was all like that. I knew from history, back in the days when it was called Oak that it was a pretty delightful language. Then WS-* and Enterprise OO happened, and I assumed that's where it all went...

I write NLP software in Java and we don't have any of that crap. We have had a couple devs pass through from that world, but we have largely avoided any of the architecture astronaut crap that plagues enterprise development.

It's a shame that the name "Java" has become synonymous with it, since it really isn't a bad language (as of Java 7, at least).

Why is Java 8 even worse though? It supposedly introduces several mechanisms to reduce redundancy?
ravioli-code
Senior programmer? ...

Shouldn't a junior programmer be able to solve fizzbuzz?

I'm light years away from being senior, but I can write functions like fizzbuzz in 10 seconds and can't find a junior job

> Shouldn't a junior programmer be able to solve fizz buzz?

Yes, which is why when I would ask it of a someone who calls themselves a senior programmer I was dumbfounded at how many could not answer the question.

FWIW, please be mindful of your biases. I recently had an interviewer with a major bank conglomerate who had some silly puzzle. I outlined a system for solving it in algorithmic notation, and the interviewer had no idea that such a response was appropriate and said sorry, that they were looking for someone with programming experience, not specific, just "many languages" ... Not saying you do this, but what if someone provided Fizz Buzz in COQ or Elixir, or some kind of rule based solver? Honestly a lot of that may look like gibberish to me if I was looking just for a way to dismiss people. Or what if they never heard of Fizz Buzz? Anyway... my brain starts to fixate on all of these corner case scenarios in hiring where you're screwed because something "easy" never does solve the hard problem of hiring. What if the person couldn't do it because they think you're trying to trick them? Anyway... best of luck in your hiring.
I hate puzzles too, especially the gotcha ones with esoteric knowledge required.

But for FizzBuzz I explain the problem, explain that there is no trick and the simplest answer that produces the correct output will be fine. To solve it you need to know about building a loop, what the mod operator does, and maybe keeping state depending on how you build it. I tell them to write it in the language they know best. None of those things should be "gotchas" in your favorite language.

You don't need mod, loops or recursion to solve it. For instance:

    local remove = table.remove
    local insert = table.insert
    local print  = print
    
    local sequence = { 
        false  , false  , 'Fizz' , false  , 'Buzz',
        'Fizz' , false  , false  , 'Fizz' , 'Buzz' ,
        false  , 'Fizz' , false  , false  , 'FizzBuzz'
    }
    
    local function o(v)
      local name = remove(sequence,1)
      insert(sequence,name)
      print(name or v)
      return v + 1
    end
    
    local function t(v)
      return o(o(o(o(o(o(o(o(o(o(v))))))))))
    end
    
    local function h(v)
      t(t(t(t(t(t(t(t(t(t(v))))))))))
    end
    
    h(1)
It does rely upon state (the sequence table) but even that could probably be worked around if Lua had a slice syntax.
You're right, it doesn't (clever solution BTW).

Although we could debate that the way you call o and t is just you manually expanding a loop. In which case I would question why you didn't just use a loop. :)

I could also debate with you that you had to at least understand what mod is to build the sequence.

I would also give you bonus points for detecting that it is a repeating pattern.

But the point is, you solved it, you wrote code that could solve it. So now I know that you're at least capable of writing basic code, and we've got a couple of things to talk about!

No loops, no sequence, one horrific line. :)

    Console.Write(String.Join("\r\n",  Enumerable.Range(1, 100).Select(x => x % 15 == 0 ? "FizzBuzz" : x % 5 == 0 ? "Buzz" : x % 3 == 0 ? "Fizz" : x.ToString())));
One of my friends failed an interview out of college where they asked him fizz buzz, and [using python] he created an array [list(range(1,101))] and then overwrote multiples of 3 with "fizz" multiples of 5 with "buzz" and multiples of 15 with "fizzbuzz."

Because it was an unconventional solution, the interviewer didn't like it.

That's exactly how I'd do it! What's supposed to be the better way? Modulo/division by three and five?

  for(var i = 1; i <= 100; i++) {
    a[fizz +=3] = "fizz" + (a[fizz] || "");
    a[buzz +=5] = "buzz";
    print(a[i] || i);
  }
If someone answered FizzBuzz in Coq, I'd question their judgement. On the other hand, usually in situations like that I'd ask the interviewee to explain their solution. If they can explain it well, that's fine.
> what if someone provided Fizz Buzz in COQ or Elixir

Wie waere es fuer dich, wenn ich in einer Sprache antworte, die du wahrscheinlich nicht verstehst?

Zavisi. Ako si mi rekao da mogu da koristim bilo koji jezik, onda je na tebi da pronađeš prevod ;)
What are the odds my wife's language would show up in an HN comment?
Au secours! J'ai compris une-et-demi de ces réponses. Време ли е за Физз-Бузз?
Last year I interviewed about 5 or 6 senior developers for a .Net role. All took 10 or more minutes to complete the fizzbuzz exercise. One couldn't remember the modulo operator. One of the fastest candidates handed me his solution and it didn't compile (this guy's CV also had all of the latest and greatest frameworks listed in his experience).

Fine, I accept that there's performance anxiety in interview situations, but if I'm trying out for the Broncos I can't blame it nervousness that I couldn't kick the ball.

10 seconds with good test coverage is quite nice.
I do warm-up problems like this even when starting hour long code interviews. I don't like FizzBuzz though, I like to use same difficulty questions that can be expanded onto other tasks, a point-in-rect sample question can turn into a real bounding box question.
The thing is, there are a lot of people whose ability to code can be verified pretty easily without wasting the time of multiple people in your company. So why not do that?