TITLE: Five digit numbers with each digit from the set {1, 2, 3, 4}: numbers with an even digit sum and numbers with more even than odd digits
QUESTION [6 upvotes]: This is a question in a book that I am studying, and I have attempted to answer it but got it wrong.
There were two parts that I wrong.
The question is about five digit numbers where the digits are 1, 2, 3, or 4.
The first part asked how many numbers were such that the sum of the digits was even. My answer was
$$
  \binom{5}{0}
(2^5) +
\binom{5}{2}
(2^2)(2^3)+
\binom{5}{4}(2^4)(2)
$$
My thought process was to add up all of the possible numbers with an even number of odd digits. $\binom{5}{0}$ is for choosing 0 out of the 5 digits to be odd, and the following $2^5$ is for the remaining 5 digits, each of which has two choices for even numbers. $\binom{5}{2}$ is for choosing 2 out of the 5 digits to be odd, followed by $2^2$ to represent the two odd digits having 2 odd numbers to choose from, and the last $2^3$ to represent the remaining 3 digits having 2 even numbers to choose from. The last terms works similarly.
The second part asked how many numbers had more even digits than odd digits. My thought process here was that I needed at least 3 even digits, so I needed to choose 3 digits out of 5, assign them even digits, and then freely assign the remaining 2 digits. So, my answer was
$$
\binom{5}{3}(2)(4^2)
$$
The book's answer for the first part was to choose 4 digits without restriction and then choose an even or odd last digit to make the sum even:
$$(4^4)(2)$$
For the second part, it added up the all 3 even-digit numbers, 4 even-digit numbers, and 5 even-digit numbers:
$$
  \binom{5}{3}
(2^3)(2^2) +
\binom{5}{4}
(2^4)(2)+
\binom{5}{5}(2^5)
$$
I understand why the book's answers work, but I'm not sure why my answers do not work. How should I have approached these questions?

REPLY [5 votes]: Your approach to the first part is correct and so is the answer. Please note that -
$\displaystyle \small \binom{5}{0} \cdot 2^5 +\binom{5}{2} \cdot 2^5 + \binom{5}{4} \cdot 2^5 = 512$
and so is the book answer,
$\displaystyle \small 2 \cdot 4^4 = 512$. The book goes by the fact that we have $4$ digits - $ \{1, 2, 3, 4$ }, exactly two even and two odd to choose from. When you assign first four digits unrestricted, it will give you equal  count of numbers that have odd sum and even sum. In other words, we will get $\displaystyle \small \frac{1}{2} \cdot 4^4$ numbers of $\small 4$ digits with odd sum and same count for numbers with even sum. Now if the sum of first four digits is odd, we can assign fifth digit as either $1$ or $3$, two choices. If the sum is even, you can assign fifth digit as either $ \small 2$ or $\small 4$.
Coming to second part, please note that we are finding numbers that have more even digits than odd.
But your working $\displaystyle \binom{5}{3} \cdot 2 \cdot 4^2$ has duplicates. Please note that you are first choosing $3$ places and assigning even digits. Then for remaining two digits, you are assigning unrestricted. Think as an example what happens when you choose first three digits as part of $ \small {5 \choose 3}$ and assign $2$ or $4$. The last two digits can again have $2$ or $4$ when you assign last two digits unrestricted. Similarly when you chose last $3$ digits as part of $ \small {5 \choose 3}$, you can again have $2$ or $4$ in the first two digits as you are assigning first two digits unrestricted. This is just one example of how duplicates come in your solution.
One comment on the book solution for second part, it is not optimal either. As these are $5$ digit numbers made from $ \small \{1, 2, 3, 4 \}$, you cannot have equal count of even and odd digits and due to symmetry, there will be equal count of numbers where there are more even digits or more odd digits. That leads to an answer of $ \ \displaystyle \small \frac{1}{2} \cdot 4^5 = 512$. The book answer works out to the same.