News for hackers. Stuff that matters.
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by AshFurrow on Thursday January 19, 2012 @11:25AM (#3485130)
You're checking for a null local variable value in the third conditional, but appending to that same variable in the first two, which would either cause a runtime error in most languages or never pass the third conditional.
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by jpeterson on Thursday January 19, 2012 @11:30AM (#3485153)
This was my first thought as well. If he instead initializes:

    var result = "";
and checks for:

    if (result.length === 0) {
    ...
in the third conditional, is there still a bug?
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by AshFurrow on Thursday January 19, 2012 @11:39AM (#3485217)
Yes, he specifies the conditional is "examine the variable result; if it is still null ..."
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by extension on Thursday January 19, 2012 @12:20PM (#3485449)
In Ruby, for example, you could append a string to nil by interpolating the nil into a string literal, or various other ways. Seeing as he didn't specify the language, what the variable was initialized to, or what exactly "append" means, we can only assume that these imaginary things behave as intended.
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by mikeryan on Thursday January 19, 2012 @11:50AM (#3485278)
The bug in the interview is not having a whiteboard or paper or a computer that the interviewee can use.

Forcing anyone to do a coding exercise in their head is ridiculous.

Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by steven_h on Thursday January 19, 2012 @11:34AM (#3485179)
It might have been when he initialized the variable result.

He goes on to append strings to this variable which would lead me to believe it has some value that you can append to.

This would make the third conditional where he checks for null to fail, he should check for an empty string.

Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by waffle_ss on Thursday January 19, 2012 @12:34PM (#3485535)
This is my conclusion as well. To wit, an approximate translation of his method into Ruby:

  fizzbuzz = (1..100).to_a.map do |i|
    result = "" # 1:23 initialize a variable
    result += "Fizz" if i % 3 == 0
    result += "Buzz" if i % 5 == 0
    result = i.to_s if result.nil?
    result
  end
The corrected solution would be to change `result.nil?` to `result.empty?`, i.e. checking for "empty string" instead of "null".
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by jersni on Thursday January 19, 2012 @12:27PM (#3485493)
I see paper and pen/pencil in that office...

He doesn't ever print out result either

Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by mobjedgar on Thursday January 19, 2012 @11:16AM (#3485079)
Hahaha genius. "...What??" Oh, and I have no idea what the bug is.
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by denzil_correa on Thursday January 19, 2012 @12:13PM (#3485401)
Shouldn't he check the divisibility by both 3 AND 5 first?
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by extension on Thursday January 19, 2012 @12:25PM (#3485475)
No, in that case the first two conditionals will both pass and the result will end up as "FizzBuzz".
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by denzil_correa on Monday January 23, 2012 @03:46PM (#3502059)
Well, that would depend on the print statement. Generally, all of them have new lines. Even if they don't you would have to generate new lines appropriately otherwise the next number would print right next to Fizz.

PS : My assumption is that you need to print each number or Fizz or Buzz or FizzBuzz in a separate line.

Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by splatterdash on Thursday January 19, 2012 @02:58PM (#3486331)
Well, you can check for 3 AND 5 first (or check for 15 altogether). This is if you have two subsequent checks for 3 and for 5.
Re:Find the Bug in my Fizz Buzz Interview (2:47 video) by lucian1900 on Thursday January 19, 2012 @11:53AM (#3485293)
That video is so fucking annoying. Why not just show a page with the fucking text?