Fizz Buzz without conditionals or booleans
evanhahn.com
Fizz Buzz without conditionals or booleans
1–10 of 72 posts
Re: Fizz Buzz without conditionals or booleans
#2Answer: Modulo or adding "%3" and "%5" before masking it
Re: Fizz Buzz without conditionals or booleans
#3[deleted]
Re: Fizz Buzz without conditionals or booleans
#4Much like stop50's solution, I also used the modulo, but I make use of the terminal to overwrite the number. It's only three lines of code, but I split up the list to be more readable on here.
This works from 1 to 100000000000000000000 before it overflows, and 100000000000000000000 is above the max size of a unsigned 64 bit int, so I feel that it's good enough
fizzbuzz = [
"fizzbuzz ",
"", "",
"fizz ",
"",
"buzz ",
"fizz ",
"", "",
"fizz ",
"buzz ",
"",
"fizz ",
"", "" ]
for n in range(99999999999999999999-30, 100000000000000000000):
print(f"{n}\r{fizzbuzz[n%15]}")Re: Fizz Buzz without conditionals or booleans
#5No matter how you calculate FizzBuzz, it is bad engineering.
const Fizzbuzz = "1 2. Fizz, 4 ... "
Print FizzbuzzRe: Fizz Buzz without conditionals or booleans
#6No matter how you calculate FizzBuzz, it is bad engineering. const Fizzbuzz = "1 2. Fizz, 4 ... " Print Fizzbuzz
What’s the point of the game without booleans?
Re: Fizz Buzz without conditionals or booleans
#7package main
import (
"fmt"
"math/rand"
)
var fb [4]string = [4]string{"", "fizz", "buzz", "fizzbuzz"}
var lucky int64 = 176064004
func main() {
for i := 1; i Re: Fizz Buzz without conditionals or booleans
#8I always wanted to write this with duff's device. switch with fall through is almost never a good thing but it allows for some 'interesting' tricks. Wouldn't be hard, but I have kids so finding half an hour to concentrate is hard.
Re: Fizz Buzz without conditionals or booleans
#9vim +'exec "norm 99o"|%s/$/\=line(".")/|vert new|exec "norm i\r\rFizz\r\rBuzz\rFizz\r\r\rFizz\rBuzz\r\rFizz\r\r\rFizzBuzz"|exec "norm gg\G$y"|bd!|let @q="10a \\"0gpj"|exec "norm gg10@q"|silent /100/+,$d|silent %s/\d\+\s\+\(\w\+\)/\1'
Now I see it's the same solution as in the post.
Edit: Actually all you need is vim -es +'exec "norm! i\r\rFizz\r\rBuzz\rFizz\r\r\rFizz\rBuzz\r\rFizz\r\r\rFizzBuzz\Vggy7P101GdG"|%s/^$/\=line(".")/|%p|q!'
Re: Fizz Buzz without conditionals or booleans
#10What's a "disguised Boolean" in this context?