4 ms·
Do you tell them what the "mod" operator is before giving it? The failure rate of FizzBuzz has always struck me as depending on the idea that you can do a lot
by XorNot 2y ago
Do you tell them what the "mod" operator is before giving it?
The failure rate of FizzBuzz has always struck me as depending on the idea that you can do a lot of programming and just never need that operator.
- sensanaty 2y agoYeah I know how to implement FizzBuzz since it's such a meme, but I've basically never used the mod operator in real code. Maybe it comes up in more math-y code I suppose, but for most backend/frontend/SQL code I've never reached for it.
- stefan_ 2y agoMore mathy code like checking if a number is even or splitting a total number of seconds into minutes and seconds?
- vundercind 2y agoI’ve used it for coloring alternating lines differently in UI code, and as a lazy way to log only every so many times some loop runs. I only know it well because it was covered near the beginning of one of the first programming books I picked up (on Perl 5) and it stuck with me because it seemed wild to me that they had an operator for that.
- wruza 2y agofor (…) { heavy_op(); if (i % 100 == 0) { printf("not dead"); } Classic
- kmoser 2y agoDepends on the application. I've written accounting software that makes use of it, along with heavy use of floor() and ceil(), including in SQL.
- eschneider 2y agoEven if that's so, modulus (or at least the concept of remainders) are elementary school math and any competent programmer could bang together an (inefficient) modulus operator in a few minutes. So even in a language w/o a mod operator, it's not a hard problem if you understand how to solve problems with code.
- azornathogron 2y agoYou don't actually need mod to do fizzbuzz, even if that's the most obvious way for people who know what mod is. But without any "real" math at all you can do it with, eg, two counters and some if statements. Or if you recognise that there's a repeating pattern you can work out that pattern manually and just write code to emit it over and over.
- arethuza 2y agoI once worked with a guy who was an incredibly good developer and I was surprised when he didn't see anything special about the number 64 (i.e. a power of two) - turns out that he'd never done any bit fiddling type work so he hadn't had to think in those terms. It wouldn't surprise me if a lot of people hadn't heard of "mod" either....
- dkdbejwi383 2y agoA huge majority of programming work is basically just CRUD stuff and other data shuffling. It’s not surprising that someone wouldn’t have needed to work with big shifting (or modulus) in that case.
- arethuza 2y agoHe was an expert in complex multi-organisation enterprise integration and was the go to guy to work out why horrific distributed transactions were failing... He also did a lot of cool stuff as side projects in his own time - just none of them happened to involve worrying about powers of 2.
- sjaak 2y agoNo but I permit internet access as long as they don't search for the solution (I trust them not to do that, and don't monitor what they do)
- DonHopkins 2y agoYou're too trusting.
- ownagefool 2y agoWhilst I agree, his point still stands that either they do it fast or never.
- daemin 2y agoUnless you specifically want a compiling and running version of FizzBuzz you don't actually need to use or know about the mod operator. At least for me it would be sufficient if the person used a function like IsMultipleOf(x, m), or Remainder(x, n). This would at least make it clear what the function did even if they didn't get the exact operator. The other thing to note is that the mod operator works differently on different languages and platforms.
- DonHopkins 2y ago> the mod operator works differently on different languages and platforms Not with positive inputs, which is the domain of FizzBuzz. Even if you don't know what "mod" means, if you have no idea know what a remainder is, and that the problem calls for it, and you can't derive the mod operator using integer addition, subtraction, multiplication, and division, then your math and problem solving skills are pretty weak, which FizzBuzz tests.
- ownagefool 2y agoI stopped using fizz buzz a long time ago. 90% of candidates can't define a 2d array in their chosen language without first filtering the candidates, where you get to about 50%.