08-09-2013 06:34 PM
Did all this somehow turn into a Rube Goldberg competition? 😄
08-10-2013 08:36 AM
For me: yes 🙂
08-12-2013 10:11 AM
jcarmody wrote:
@Henrik Volkers wrote:
How about a one line regular expression someone?
Hmmm...
I don't know if it's possible with one line, but I had to try this puzzle using regex,
"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books
08-12-2013 10:44 AM
Here's two ideas for a Rube Goldberg version of fizzbuzz... 😄
1) A VI that, for every integer n, run queries on Wolfram Alpha to check whether n is divisible by 3 and 5. Use the true or false responses to build your list of fizzes and buzzes. Remember to put in a nice long delay in your loop to avoid being blacklisted for denial of service...
2) Add the digits of the integer n together, and check whether the sum is divisible by three. Check the last digit to see whether it's 0 or 5, and proceed. You could be lazy and use Q&R to check the divisibility of the sum, but why stop there? This is supposed to be a Rube, goddamnit!
Actually, thinking about it, using the second allows you to test huge numbers:
04-14-2015 02:29 AM
Fizzbuzz mentioned on Codeless Code, here - http://thecodelesscode.com/case/187
06-30-2015 12:53 PM
Pardon the ressurection, but I just read this thread and had to claim the least number of functions. Would have been less if I didn't have to stop at 100.
06-30-2021 01:05 PM - edited 06-30-2021 01:32 PM
Resurrecting the thread after exactly six years with a Python/regex solution:
import re
for i in range(1,101):
out = ''
if(re.search('^(0|1(01*0)*1)*$', bin(i)[2:])): out = 'FIZZ'
if(re.search('[0-9]?[05]$', str(i))) : out += 'BUZZ'
if(out == ''): out = str(i)
print(out)
07-01-2021 03:19 AM
@jcarmody wrote:
Resurrecting the thread after exactly six years with a Python/regex solution:
import re for i in range(1,101): out = '' if(re.search('^(0|1(01*0)*1)*$', bin(i)[2:])): out = 'FIZZ' if(re.search('[0-9]?[05]$', str(i))) : out += 'BUZZ' if(out == ''): out = str(i) print(out)
That source is flawed 😋.
Requirements clearly state to output "Fizz", "Buzz" and "FizzBuzz". Not "FIZZ", "BUZZ" and "FIZZBUZZ":
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
07-05-2021 01:02 AM
I do love my selects (a back to the basics code)
07-05-2021 09:46 AM
@AeroSoul wrote:
I do love my selects (a back to the basics code)
So basically this ancient thread went full circle, because that's what started it all. Except that you now do a lot of string manipulations that you throw away in most cases a nanosecond later. So why do them unless needed? Also note that there is an "empty string?" primitive.
Compare that to the simplicity of e.g. my version.