Live data from Hacker News

Fizzbuzz, Interviews, And Overthinking

dave.fayr.am

11–20 of 115 posts

Re: Fizzbuzz, Interviews, And Overthinking

#11

We're five years into this, and here's yet another weekly column from a person who has just heard about it and is champing at the bit to prove both he can write FizzBuzz and all the other implementations are not as good as his. It will be a miracle if this thread doesn't turn into a chain of "even better" solutions, like all the other threads that came before it. In this week's installment, the variation where it is…

I can't help but feel like you didn't read the article. The entire thing is basically an excuse to tell you about monoids.

It's like a super long joke where the punch line comes way too late. But instead of a punch line it's monoids and instead of being funny it's not.

P.S., hello edits!

Re: Fizzbuzz, Interviews, And Overthinking

#12

We're five years into this, and here's yet another weekly column from a person who has just heard about it and is champing at the bit to prove both he can write FizzBuzz and all the other implementations are not as good as his. It will be a miracle if this thread doesn't turn into a chain of "even better" solutions, like all the other threads that came before it. In this week's installment, the variation where it is…

[deleted]

Re: Fizzbuzz, Interviews, And Overthinking

#13

I agree that Fizzbuzz can be a more interesting example of how to write code without repetition. While the author suggests that languages such as Haskell provide a unique advantage, the deciding question seems to be the availability of pre-built abstractions. Consider the following solution in Python: for i in xrange(1,101): print (('' if i%3 else 'Fizz')+('' if i%5 else 'Buzz')) or i or the even more general: mappin…

It is still crazy to me that in Python ('' or 10) == 10 # True That's like making the universe crazier one electron at a time. But yes, it's just about having the right abstractions. What's nice about the Haskell solution is that the right abstractions make the code much nicer (to my eye).

I honestly don't understand why that's crazy. Empty string evaluates as falsey, so the "or" picks the 10, which is obviously equal to 10. Or am I missing something?

Re: Fizzbuzz, Interviews, And Overthinking

#15

We're five years into this, and here's yet another weekly column from a person who has just heard about it and is champing at the bit to prove both he can write FizzBuzz and all the other implementations are not as good as his. It will be a miracle if this thread doesn't turn into a chain of "even better" solutions, like all the other threads that came before it. In this week's installment, the variation where it is…

I would prefer to force candidates to implement FizzBuzz in a language invented solely for purposes of that interview (and which will never be used again). This places all candidates on the same level.

It's probably a good thing I don't interview people for programming positions...

Re: Fizzbuzz, Interviews, And Overthinking

#16
post #13

Earlier quoted context omitted.

It is still crazy to me that in Python ('' or 10) == 10 # True That's like making the universe crazier one electron at a time. But yes, it's just about having the right abstractions. What's nice about the Haskell solution is that the right abstractions make the code much nicer (to my eye).

I honestly don't understand why that's crazy. Empty string evaluates as falsey, so the "or" picks the 10, which is obviously equal to 10. Or am I missing something?

[deleted]

Re: Fizzbuzz, Interviews, And Overthinking

#17
post #13

Earlier quoted context omitted.

It is still crazy to me that in Python ('' or 10) == 10 # True That's like making the universe crazier one electron at a time. But yes, it's just about having the right abstractions. What's nice about the Haskell solution is that the right abstractions make the code much nicer (to my eye).

I honestly don't understand why that's crazy. Empty string evaluates as falsey, so the "or" picks the 10, which is obviously equal to 10. Or am I missing something?

It just seems like a bad choice. The empty string being falsey is... very arbitrary to me. It seems like it's strictly a perl legacy thing that should be (but cannot be) reconsidered.

About as far as I am willing to go is nil punning.

Re: Fizzbuzz, Interviews, And Overthinking

#18

I agree that Fizzbuzz can be a more interesting example of how to write code without repetition. While the author suggests that languages such as Haskell provide a unique advantage, the deciding question seems to be the availability of pre-built abstractions. Consider the following solution in Python: for i in xrange(1,101): print (('' if i%3 else 'Fizz')+('' if i%5 else 'Buzz')) or i or the even more general: mappin…

My "I'm going to hell, but that's okay" C version:

  #include 
  #include 

  #define when(mod, msg) do { if((i mod) == 0) { fputs(#msg, stdout); *hit = true; } } while(0)
  #define through ; i 
Super extensible!

Re: Fizzbuzz, Interviews, And Overthinking

#19
post #7

I agree that Fizzbuzz can be a more interesting example of how to write code without repetition. While the author suggests that languages such as Haskell provide a unique advantage, the deciding question seems to be the availability of pre-built abstractions. Consider the following solution in Python: for i in xrange(1,101): print (('' if i%3 else 'Fizz')+('' if i%5 else 'Buzz')) or i or the even more general: mappin…

Just as you can write FORTRAN or COBOL in any language, you can write functional code in any language.

No you can't, as you need the language to provide a few basic building blocks, such as lambdas, and the ability to pass functions as arguments.

Re: Fizzbuzz, Interviews, And Overthinking

#20
post #14

I recently challenged people to codegolf fizzbuzz ( http://swizec.com/blog/fizzbuzz-without-ifs-in-90-char-i-wil... ) The Haskell solution was really cool: [max(show x)(concat[n|(f,n) This is much simpler and it looks easier to extend as well.

My goto ruby solution looks something like:

(1..100).map{|i|(f=[["Fizz"][i%3],["Buzz"][i%5]].join).empty? ? i:f}

Post reply on HN