Task#16
Position1
Score169,520
Best Score169,520
Points1.000

Problem Statement

You have a data stream of uint32 numbers in binary representation sending to STDIN. The byte order is little endian. For each number n print:

  • FizzBuzz if n is divisible by 3 and 5.
  • Fizz if n is divisible by 3.
  • Buzz if n is divisible by 5.
  • n (as a string) if none of the above conditions are true.

Numbers quantity is 30 000 000.

Input Generator

Random Bytes (confirmed with distcheck)

Solution Sketch

For FizzBuzz, Fizz, Buzz cases just do a memcpy.

For the other cases, use a big Constexpr LUT for going from intstring. Do a divmod with 1e5, then index into a low LUT and a high LUT. Combine, print and advance the output pointer.

Thoughts

I think this could be more competitive with some pipelining and vectorized division. Hadn’t gotten around to trying it. Maybe those who do format ints really fast can do the same here.

A complicated SIMD kernel I had made to do this in pairs ended up being slower.