I played with this the last time it was posted. The thing that I hadn’t realised makes an efficient Fizzbuzz implementation hard is that 3 is not a factor of 10. If the game were to say Fizz on multiples of 2, rather than 3, then you could fill a buffer with the correct Fizz / Buzz / FizzBuzz permutations for 10, 100, 1000, or whatever power of 10 you wanted. You’d then write this to the terminal and then go and increment the next highest digit. There’s no division anywhere near your fast path, it’s purely memory + I/O.

Because Fizz is on multiples of 3, you can generate this pattern for any multiple of 15, but 15 is not a power of 10 or an integer factor of any power of 10, so you have to handle the corners. This probably means that a solution involving actually calculating the sequence (rather than precomputing it and just updating the indexes) is likely to be optimal.

This makes me think that it would be an interesting interview question to ask a candidate how changing the rules from 3 and 5 to 2 and 5 would change how they would approach building a high-performance FizzBuzz implementation.

I think that talking about ais523 without acknowledging their contributions to esoteric language design is skipping over their most important work. I like computability theory, so their languages Three Star Programmer and The Waterfall Model are essential contributions, in my view.

This is the kind of inspired insanity I can get behind.

I played with this the last time it was posted. The thing that I hadn’t realised makes an efficient Fizzbuzz implementation hard is that 3 is not a factor of 10. If the game were to say Fizz on multiples of 2, rather than 3, then you could fill a buffer with the correct Fizz / Buzz / FizzBuzz permutations for 10, 100, 1000, or whatever power of 10 you wanted. You’d then write this to the terminal and then go and increment the next highest digit. There’s no division anywhere near your fast path, it’s purely memory + I/O.

Because Fizz is on multiples of 3, you can generate this pattern for any multiple of 15, but 15 is not a power of 10 or an integer factor of any power of 10, so you have to handle the corners. This probably means that a solution involving actually calculating the sequence (rather than precomputing it and just updating the indexes) is likely to be optimal.

This makes me think that it would be an interesting interview question to ask a candidate how changing the rules from 3 and 5 to 2 and 5 would change how they would approach building a high-performance FizzBuzz implementation.