Written on March 17, 2020

FizzBuzz without IF in 89 bytes.

A solution that requires only 89 characters and uses no if-statements is this one:

for n in range(1,101):
    y=[[n,"Buzz"],["Fizz","FizzBuzz"]]
    print(y[n%3<1][n%5<1])

FizzBuzz is a simple coding exercise: Write a program that prints the numbers from 1 (including) to 100 (including) and whenever i) the number is divisible by 15, print “FizzBuzz” instead, ii) the number is divisible by 3 but not 15, print “Fizz”, and iii) the number is divisible by 5 but not 15, print “Buzz”.

A slightly more readable version of the answer above is given here:

for n in range(1,101):
    answer=[[n     , "Buzz"],
            ["Fizz", "FizzBuzz"]]
    print(answer[n%3==0][n%5==0])

Instead of using the two (or three) if-statements for the most simple solution, we access a matrix via the modulo check. Also, checking n%3<1 is equivalent to checking n%3==0, but saves a character. The solution is especially nice, because it is not only short but also readable.