How many compositions does the integer $12$ have into three parts none of which is equal to $2$?

432 Views Asked by At

I want to find the number of compositions that satisfy the the following conditions:
$x_1 +x_2 +x_3 = 12$ and $x_i \neq 2$

  • Total $\binom{14}{2}$ compositions (weak)
  • Number of compositions where one of the parts equals $2$ is $\binom{11}{1}$
  • Number of compositions where two parts equal $2$ is $\binom{8}{0}$ or $1$
  • Number of compositions where all three parts equal $2$ is $0$

Hence the total number of such compositions are $\binom{14}{2} -\binom{3}{1} \binom{11}{1} + \binom{3}{2} = 61$

Edit: Somehow I manged to put a "-" there instead of a "+" :)

2

There are 2 best solutions below

0
On BEST ANSWER

From the context, I'll assume the parts are restricted to nonnegative integers.

Using that assumption, the correct count is $${\small{\binom{14}{2}}}-{\small{\binom{3}{1}\binom{11}{1}}}+{\small{\binom{3}{2}\binom{8}{0}}}=61$$ The subtraction of ${\large{\binom{3}{1}}}{\large{\binom{11}{1}}}$ removes each instance of two $2$'s twice, instead of one time, so they need to be added back.

0
On

I'm counting $61$, assuming nonnegative integers:

n = 0;
N = [0, 1, 3:12];
for x = N,
    for y = N,
        for z = [0, 1, 3:(12-x-y)],
            if (x+y+z==12),
                ++n;
            end
        end
    end
end
n,

For positive integers (removing the singleton zeroes in the code), the count lowers to $31$.