a) Determine the number of ways to colour a 1 by n grid using the colours red and white if an even number of squares are to be coloured red.
Note that n is greater than or equal to 1 and the number of red squares could be 0.
I know I must consider the cases of n being even and odd, and determine the sum, from zero to n of the squares being red, where the number of red squares is even. But I just want to make sure I haven’t missed any arrangements by saying a) is $2^{n-1}$ when n is even and $2^{n-1}-1$ when n is odd.
b) Determine the number of ways to colour the squares using red, white and blue if an even number of squares are to be coloured red.
For this case, I can have arrangements including red only, white only, blue only, white and blue only, red and white only, red and blue only, and finally all three colours.
Thank you for any help provided.
For part (a): If $n$ is odd, then any arrangement will have either an even number of red squares or an even number of white squares (but not both). Reversing white and red if necessary gives an even number of red squares. So the answer in this case is one half of the total number of arrangements, or $2^{n-1}$.
If $n$ is even, then any arrangement has either an even number of both red and white squares or an odd number of both. But there is a bijection between the latter set and the former by switching the color of the last square. Thus in this case as well the total number of arrangements with an even number of red squares is $2^{n-1}$.
For the general case, part (b), suppose there are $c$ colors and you want to know the number of arrangements with an even number of red colors. Suppose first that the number of squares, $2n$, is even. For each $k$ from $0$ to $2n$ we first choose the number of arrangements with $2k$ red squares in $\binom{2n}{2k}$ ways, and then any arrangement of the remaining squares using $c-1$ colors. Then the total number of such arrangements is $$\sum_{k=0}^n \binom{2n}{2k}(c-1)^{2n-2k} = \sum_{k=0}^n \binom{2n}{2n-2k}(c-1)^{2n-2k} = \sum_{k=0}^n \binom{2n}{2k}(c-1)^{2k}.$$ This can be seen to be an expansion of the formula $$\frac{1}{2}(((c-1)+1)^{2n} + ((c-1)-1)^{2n}) = \frac{1}{2}(c^{2n}+(c-2)^{2n}).$$ In your case, with $c=3$, one gets for the number of arrangements with an even number of squares $$\frac{1}{2}(3^{2n}+1).$$ For an odd number of squares, the computation is very similar, and the answer comes out to be $$\frac{1}{2}(c^{2n+1}+(c-2)^{2n+1}).$$