
The Fastest FizzBuzz in the West - traverseda
https://www.promptworks.com/blog/the-fastest-fizzbuzz-in-the-west?utm_source=python&utm_medium=reddit&utm_campaign=FizzBuzz
======
avolcano
The author using FizzBuzz as a comical-but-recognizable launching point for
demonstrating introducing the basics of programming language implementation
and RPLY, and the HN comments being nothing but people yelling about FizzBuzz,
is a pretty amazing summary of the state Hacker News comments. It also makes
me think next time I have a technical article, I should prepend some
controversial statement to it just to generate buzz :V

In all seriousness: this is a really cool article, thanks for sharing! I'm not
very familiar with RPython or RPLY and it was really cool to see a "real-
world" example of it. I actually just read through something similar in
JavaScript ([https://github.com/thejameskyle/the-super-tiny-
compiler](https://github.com/thejameskyle/the-super-tiny-compiler)). I really
should give language implementation a shot one of these days (closest I've
come is writing a JSON lexer & parser); always like to read about it!

~~~
_asummers
There was a project linked to HN in ~December or November of last year about
building your own Lisp, which would probably be a terrific jump off point into
that, if you're looking for a place to get started.

~~~
kornish
Not sure which you're referring to, but this is a very digestible overview on
PL implementation by HN's very own nostrademons.

[https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_...](https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours)

~~~
_asummers
I THINK this is the one I'm thinking of, the timeline matches.

[https://news.ycombinator.com/item?id=10474717](https://news.ycombinator.com/item?id=10474717)

------
xeniak
Dustin seems to take offence at the idea that FizzBuzz would be used in a
technical interview to screen job candidates.

Jeff Atwood on the other hand thinks it's a great way to filter out
"developers" who can't program their way out of a wet paper bag:

[https://blog.codinghorror.com/why-cant-programmers-
program/](https://blog.codinghorror.com/why-cant-programmers-program/)

~~~
sotojuan
A lot of the people that hate on programming interviews haven't had to
interview candidates. Don't get me wrong, interviews are still annoying and
sorta broken but your perspective really changes when you're the one filtering
candidates.

~~~
flukus
Can't we hate them and also hate the fact that they are necessary?

~~~
sotojuan
Yes, that's what I do!

------
kevin_thibedeau
> it's is a mythical interview question to see how well you can write code in
> an environment in which you will never actually write code.

> The goal is to sufficiently intimidate junior developers so they will know
> to steer clear of your organization.

We use fizzbuzz on senior devs claiming to be C++ experts and they stumble on
it regularly.

~~~
svckr
Saying one is a C++ expert is a pretty extraordinary claim and should require
extraordinary evidence :)

I'm regularly intimidated by positions looking for capital s Senior C++
developers, because no matter how deep my knowledge goes, memory model,
templates substitution rules and all, I realize there's dragons lurking behind
every corner. Now, C is a language that fits in my head, C++ … not so much,
but maybe that's because it is not part of my daily routine.

I'd suggest you look for _productive C++ developers_ that know their
limitations. I think you might even get better candidates that way.

~~~
flukus
> I'd suggest you look for _productive C++ developers_ that know their
> limitations. I think you might even get better candidates that way.

It sounds like they are. The "expert" is a self described one.

------
andrewstuart
I'll put it out there.

"No programming test these days is valid without full access to Google."

This is the opposite to conventional wisdom which says that programming tests
must be done in an isolated environment without access to the web "please
deposit your mobile phone at the testing room door".

No programming is done in isolation so the only way to effectively and
realistically test someone is to see what results they get in a real world
environment, which means full web access.

Don't get me wrong - I am very much against the idea that "I don't need to
understand fundamentals cause I can Google everything" \- only the misguided
think that. What I do think is that recruiting needs to be about measuring
real world results - that means full access to Google and StackOverflow.

THE most critical skill that is almost NEVER meaured - and in fact is
generally avoided measuring - is the programmers skills in Googling to solve
unfamiliar problems. The best programmers ride Google and StackOverflow like
racehorse jockeys ride the ponies.

~~~
jimjimjim
I was with you until the "The best programmers..." line. They are the best
programmers for whatever reasons were important in whatever it was that they
were doing.

When I have asked interviewees to do anything on a whiteboard I've generally
said 'pseudo-code is fine or whatever language your comfortable in or even
diagram it'. What I'm looking for is an awareness of high-level concepts and
ideas. People may not google for something if they don't know to google for
it.

------
ayuvar
I won't be happy until I see someone do FizzBuzz in silicon.

~~~
jschwartzi
This is apparently a FizzBuzz accelerator written in Verilog:

[https://gist.github.com/houmei/4649209](https://gist.github.com/houmei/4649209)

~~~
toomanybeersies
Video of it in action:
[https://www.youtube.com/watch?v=EJAQTHFFgY4](https://www.youtube.com/watch?v=EJAQTHFFgY4)

------
hoodoof
All these garbage tests need to go into the standard lib.

    
    
      from jobinterviews import fizzbuzz, redblacktree, irrelevanttheoreticaltest
    
      fizzbuzz()
      redblacktree()
      irrelevanttheoreticaltest()

------
jessaustin
There seem to be a lot of skipped rules. I think it has something to do with:

    
    
      all-1b4059b…-46d74bf1.js:5 Uncaught TypeError: Cannot read property 'length' of null

------
rrobukef
I can't help but notice that it doesn't help when the order of the strings
need to change. Consider the following problem: For multiples

* of 105 print 'buzzfizzfuzz' * of 35 print 'buzzfuzz' * of 21 print 'fuzzfizz' * of 15 print 'fizzbuzz' * of 7 print 'fuzz' * of 5 print 'buzz' * of 3 print 'fizz'

~~~
di
Why would the order of strings need to change? I would assume that if
15=="fizzbuzz" than 105 would be "fizzbuzzfuzz", not "buzzfizzfuzz".

------
vikiomega9
Loved it! I learnt something about compiler design today!!

------
ratfacemcgee
> We don't use FizzBuzz or anything like it when we screen potential new hires
> at PromptWorks, and I've never actually been asked to implement it.

welp

------
fucknode
Whenever asked to do fizzbuzz i always do it in ruby

(1..100).each{|n| p "#{'fizz' if n%3==0}#{'buzz' if n%5==0}"}

~~~
flukus
Do you always fail the test? You forgot what happens when n is divisible by 3
and 5.

~~~
ryanplant-au
There doesn't need to be a separate test for 3 and 5, his example already
handles it properly -- it's two separate if statements, not an if/elsif, so
it'll just meet both conditions and print "fizz" then "buzz" to create
"fizzbuzz". What's forgotten is printing the number alone if it's divisible by
neither.

Fizzbuzz is one of those problems where there's really no clever hidden golfy
solution better than the plain old first-reaction naive approach: an iteration
with if/elsif/elsif/else.

~~~
wott
> _Fizzbuzz is one of those problems where there 's really no clever hidden
> golfy solution better than the plain old first-reaction naive approach: an
> iteration with if/elsif/elsif/else._

There are. With a funky calculation.

For example, taken from Rosetta C version:

    
    
      for (int i=0;++i<101;puts("")) {
        char f[] = "FizzBuzz%d";
        f[8-i%5&12]=0;
        printf (f+(-i%3&4+f[8]/8), i);
      }
    

You might say the calculations are hidden if/else, but well...

~~~
jgh
It's possible to do with a switch statement as well (in C).

Edit: Would be nice if the original author of that code snippet threw in some
parentheses for a little clarity with the operator precedence.

