Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was actually asked Fizz Buzz in an interview once, but I did not have this solution at the time.

My favorite FizzBuzz solution is actually:

``` ->(n){[[["Fizz"][n%3],["Buzz"][n%5]].join].find(->{n}){|w| w if !w.empty?}} ```

This is Ruby, of course, probably something very similar can be done in several other languages.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: