3 ms·
For any implementation you can manufacture an example which will require a person to re-structure their code. Additionally, using %15 is not DRY. If the spec c
by Doji 12y ago
For any implementation you can manufacture an example which will require a person to re-structure their code.
Additionally, using %15 is not DRY. If the spec changes from saying "Fizz" on multiples of 3 to saying "Fizz" on multiples of 4, then you will have to also update 15->20. If you forget to do this, you have a bug.
The correct implementation is dependent on the problem's context, and such context is not available with the FizzBuzz problem.
- tracker1 12y agoIf you're using something like JS, where strings are truthy, you can always do something like this... https://gist.github.com/tracker1/d58fa1f83ab17d37eb2c https://gist.github.com/tracker1/d58fa1f83ab17d37eb2c
- masukomi 12y agoPart of my point (which i obviosuly didn't communicate well) is that Fizz concatenated with Buzz is a premature optimization. It's the developer taking advantage of a linguistic coincience. The instructions are to output 3 different strings based on %3, %5, or %3 and %5. I have never seen a set of fizzbuzz instructions that actually specified that the last option should be a concatenation of the 1st two. It's always specified as a 3rd string that people independently notice is a concatenation of the two.