1. 10
    1. 3

      I know why it works 😈

      1. 3

        Can you enlighten me? It appears to parse a string containing giant polynomials and do some kind of iterative approximation, but I have no idea how the hell you get fizzbuzz out of that.

        1. 6

          The string contains just one polynomial, of degree 99. I’m fairly sure that the function calculatePolynomial is just evaluating the value at a given input x, not doing any kind of iterative approximation.

          If you have a set of n desired points for a curve to intersect, you can define a polynomial of degree n-1 to intersect them. For example, if I want a function f such that f(0) = 1, f(1) = 37, and f(2) = -3, I can find a polynomial of degree 2 (i.e. a quadratic) that fits these points: f(x) = -38x^2 + 74x + 1. So, a polynomial of degree 99 can intersect 100 chosen values.

          In this case, the author has chosen those 100 values such that they are the unsigned long long representation of the ASCII strings “1”, “2”, “Fizz”, “4”, “Buzz”, etc.