I missed this thread when it originally went down, but having struck upon it now via, yes, vanity searching, I’ll note that, for what it’s worth, there IS a closed-form solution for this problem! (I mean, I’m fond of saying that “closed-form” is a silly and subjective concept, but at any rate, this will be the sort of thing most everyone calls “closed-form”).

The formula is this: Let f(x) = (x + 1) * (x + 2)/2, and let g(x) = f(floor(x/4)). Then the number of ways to make a total of n using white (1 pt), red (2 pt), and blue (4 pt) chips is g(n) + g(n - 2).

For example, when n = 12, we have that g(n) + g(n - 2) = f(floor(12/4)) + f(floor(10/4)) = f(3) + f(2) = 4 * 5/2 + 3 * 4/2 = 10 + 6 = 16. [As a sanity check, this matches the enumeration already done in the thread.]. As another example, when n = 103, we have that g(n) + g(n - 2) = f(floor(25.75)) + f(floor(25.25)) = f(25) + f(25) = (25 + 1) * (25 + 2) = 702. [It would be much more tedious to get to that with the Wolfram Alpha power series expander!]

Where does this formula come from?

Well, first of all, suppose we were forced to use an even number of red chips. I.e., suppose that instead of single red chips, we only had access to red-pairs, each pair worth 4 pts. Then, n mod 4 (i.e., the remainder when n is divided by 4) would have to match the number of white chips used mod 4. After putting in that many white chips for sure (0, 1, 2, or 3), the remaining number of white chips used has to be a multiple of 4; i.e., the remaining white chips have to be deployed in quadruplets, each quadruplet worth 4 pts. At this point, the question reduces to how many ways we can pick precisely floor(n/4) out of white-quadruplets, red-pairs, and blue chips. The standard “stars-and-bars” argument tells us the number of ways to pick 3 quantities summing to x is f(x) [i.e., (x + 2) choose 2; i.e., the number of ways to intermix, in some sequence, x many stars with 2 bars, thus creating 3 groups of stars totaling to x], and thus we find we can do this in f(floor(n/4)) = g(n) many ways.

That’s if we’re forced to use an even number of red chips. But we could possibly use an odd number of red chips! That’s ok; to make n with an odd number of red chips is to same as to toss in one red chip and then make the remaining n - 2 with an even number of red chips. And so the number of ways to do so will be g(n - 2), and adding these together gives the total quantity we are interested in.

I wrote this out without explicit resort to the generating series from before, but if you like, we can think of this in terms of those as well: this closed form arises from re-expressing 1/((1 - x)(1 - x[sup]2[/sup])(1 - x[sup]4[/sup])) as (1 + x[sup]2[/sup])(1 + x + x[sup]2[/sup] + x[sup]3[/sup])/(1 - x[sup]4[/sup])[sup]3[/sup]. The (1 + x[sup]2[/sup]) corresponds to whether we use an even or odd number of red chips. Similarly, the (1 + x + x[sup]2[/sup] + x[sup]3[/sup]) corresponds to the number of white chips mod 4.

Finally, the coefficients of the power series for 1/(1 - x[sup]4[/sup])[sup]3[/sup] have a nice closed-form because the coefficients of 1/(1 - y)[sup]3[/sup] have a nice closed form, which can be derived either by observing 1/(1 - y) is the sum of all powers of y and applying “stars-and-bars” reasoning as above, or thinking in terms of Newton’s generalized binomial theorem for (1 - y)[sup]-3[/sup] to get the coefficient of y[sup]n[/sup] as (-1)[sup]n[/sup] * (-3) choose n = (-1)[sup]n[/sup] * (-3)/1 * (-4)/2 * (-5)/3 * … * (-(n + 2))/n = (n + 2) * (n + 1)/2 (i.e., what was called f(n) above). From this, it follows that (1 + x + x[sup]2[/sup] + x[sup]3[/sup])/(1 - x[sup]4[/sup])[sup]3[/sup] has degree n coefficient equal to f(floor(n/4)) (i.e., what was called g(n) above), and therefore that the quantity of interest, which is (1 + x[sup]2[/sup]) times this, has degree n coefficient equal to g(n) + g(n - 2), the formula noted above.

Things happened to work out particularly nicely in this case, but I’ll note that ANY rational function (i.e., one polynomial divided by another) has a power series whose coefficients have a closed-form formula in the same sense, and thus we would be able to get closed-form formulae using any number of colors of chips, each worth any particular number of points. One sledgehammer approach to deriving these closed-form formulae for coefficients of arbitrary rational functions is to use so-called “partial fraction” decomposition to reduce to linear combinations of reciprocals of (x - r)[sup]p[/sup] for various complex roots r of the denominator and powers p, these reciprocals in turn being handled by the generalized binomial theorem just as above. There are also more direct ways to get at these general closed-form formulae (in the sense of not thinking about complex roots), but anyway, I’ll leave it at that for now.