News for hackers. Stuff that matters.
Re:Fizz Buzz without conditionals or booleans by susam on Wednesday November 19, 2025 @09:49AM (#45980229)
Late to the party but here's a solution I worked out using roots of unity and cosines:

  from math import cos, pi
  for n in range(1, 101):
      print([n, 'Fizz', 'Buzz', 'FizzBuzz'][round((1 + 2 * cos(2 * pi * n / 3)) / 3 + 2 * (1 + 2 * cos(2 * pi * n / 5) + 2 * cos(4 * pi * n / 5)) / 5)])
Re:Fizz Buzz without conditionals or booleans by nik9000 on Wednesday November 19, 2025 @06:59PM (#45987011)
As it should be.