4 ms·
This is a weakened version of FizzBuzz---I was taught the version that has you buzz on any number that is divisible by five OR which has a five in its base-ten
by blahedo 16y ago
This is a weakened version of FizzBuzz---I was taught the version that has you buzz on any number that is divisible by five OR which has a five in its base-ten representation. Which would be a lot harder to do without multiplication or division. :)
- rflrob 16y agoIt would actually be pretty easy to do without (explicit) multiplication or division: just convert it to a string and check text properties. Whether or not it would be any faster is another question, to which I'm almost certain the answer is no. istr = string(i) if '5' in istr or istr[-1] == '0': print "Buzz",
- unwind 16y agoFor that to be valid, in my opinion, you first have to write an integer-to-string converter that also doesn't use multiplication or division. From what I've seen (and written) of such code, that's not trivial.
- krallja 16y agoHmm... the printf("%d\n") in my solution uses division implicitly, for that very reason.