4 ms·
There's something minor that's always bothered me about the usual description of FizzBuzz: > If the number is divisible by 3, print Fizz instead of the number.
by nilkn 13y ago
There's something minor that's always bothered me about the usual description of FizzBuzz:
> If the number is divisible by 3, print Fizz instead of the number. If it’s divisible by 5, print Buzz. If it’s divisible by both 3 and 5, print FizzBuzz.
In a strict interpretation, the first two sentences could be seen as incorrect. If a number is divisible by 3, you cannot just print 'Fizz' and move on. You also have to check if it's divisible by 5.
- mantrax4 13y agoThis is why the description is good. Sure, it tests whether you can write a set of statements a computer can understand. But it also tests whether you can understand the intent behind a set of statements a human would make, without going on a diatribe about how the definition is not good enough. After all, if English was a formal strict language where only one right way existed to express something, we wouldn't need programmers, would we?
- dragonwriter 13y ago> After all, if English was a formal strict language where only one right way existed to express something, we wouldn't need programmers, would we? If you just solved the fact that one meaning can have many expressions, we'd still need programmers (and, more relevantly, system analysts) just as much. The relevant problem is that English isn't a formal strict language where a particular expression can only have one meaning (and, more importantly, that, people don't use it that way even when it superficially seems to be.) That is, the problem that requires specialized work to develop unambiguous requirements for the implementation of (among other things) information systems isn't that English maps (many expressions) -> (one meaning), but that it maps (one expression) -> (many meanings).
- nilkn 13y agoI think you could have made this point without subtly referring to my post as a "diatribe." I'm more than aware of what the intended interpretation is. Posting what I felt was a very minor and amusing observation hardly constitutes a "diatribe." > After all, if English was a formal strict language where only one right way existed to express something, we wouldn't need programmers, would we? This is very off-topic, but I'm not sure I agree with it. You're assuming that it would be easy to find the one unique way to express a given computation such that anybody could write it down. Even if English had this uniqueness property, I don't think that would be true at all.
- andreasvc 13y agoThe description is declarative, there is nothing implied about "moving on".
- dragonwriter 13y agoThe particular form of the description at issue can be interpreted (arguably, is most naturally interpreted) to direct a different outcome than is usually expected from FizzBuzz, to wit, it directs that on numbers divisible by 15 "Fizz", "Buzz", and "FizzBuzz" all should be printed, rather than just the last.
- andreasvc 13y agoThe description is underspecified, no surprise there, but that's different from claiming it's incorrect. As far as its purpose as an interview question goes noticing this interpretation would probably be seen as a good sign.
- mannykannot 13y agoIf it can be satisfied in a way that is materially different from what was intended, then it is both under-specified and incorrect. This is a not-uncommon source of errors. Natural language can be used with precision, and this is an important skill for engineers. Being able to identify ambiguity and inconsistency is an important part of that skill so yes, noticing it within a question should count in favor of the candidate. Dismissing it as being pedantic is the wrong response, because if you are working on something critical (secure communications software, for example) you need to handle ideas with precision.