3 ms·
> Also why are some people on HN talking about edge cases to FizzBuzz ? There are no edge cases that I know of unless you talk about the number zero - which isn
by irahul 14y ago
> Also why are some people on HN talking about edge cases to FizzBuzz ? There are no edge cases that I know of unless you talk about the number zero - which isn't part of the question.
I don't know about you, but I sure see it as an edge case.
# This is incorrect due to edge case.
# If divisible by 3, fizz
# If divisible by 5, buzz
# If divisible by 15, fizz buzz
# Else number
1.upto(20) do |i|
if i % 3 == 0
puts "Fizz"
elsif i % 5 == 0
puts "Buzz"
elsif i % 15 == 0
puts "FizzBuzz"
else
puts i
end
end
- ashray 14y agoI see an incorrect algorithm in your solution but I don't really see what would be called an edge case (just to explain: anything divisible by 3 will enter the first conditional and omit the last, hence the algorithm you've used is incorrect). Or maybe we're talking about different things. Could you please explain to me in words what a fizzbuzz edge case would be ?
- henrikschroder 14y agoIn my book, that's a pass, but you should have a discussion where you walk through the code and ask the interviewee what happens when i is 15, and hopefully they'll spot the problem, maybe with a little bit of nudging. But the main point of Fizzbuzz is that some people who call themselves programmers are incapable of producing a loop, some conditionals, and some print statements. Your solution had that, which is why you passed it. The point is to find the people who can't even get that part right.