Combination of a 4-digit number How many 4-digit numbers ($0000-9999$; including $0000$ and $9999$) can be formed in which the sum of first two digits  is equal to the sum of last two digits?
Assumption : every number is valid even if it starts with a zero.
For ex: $1230, 0211, 4233$ and so on...
 A: I have to admit, that this is not really a hint. But in this case I am faster writing code, than thinking. Thus:
function howmany

ds = @(n) sum(arrayfun(@str2num, num2str(n))); 
% ds = sum of digits of a number
counter = 0;
for n=0:9999
    if  ds(floor(n/100)) == ds(n-floor(n/100)*100)
        counter = counter+1;
    end
end

disp(counter)

end

Written in Matlab, but that shouldn't be the problem. The results is the same you would get by the theoretical approach of Brian M. Scott.
A: The map $(a,b,c,d)\longleftrightarrow (a,b,9-c,9-d)$ puts the desired 
4 digit numbers in a one-to-one correspondence with four digit numbers
whose digits add up to 18. This set can be counted with "stars and bars" plus
the inclusion-exclusion principle to give 
$${21\choose 3}-{4\choose 1}{11\choose 3}=670.$$
A: HINT: The possible sums of two digits are the integers from $0$ through $18$. There’s just one way to get a sum of $0$ or $18$. There are two ways to get a sum of $1$, $01$ and $10$, and two ways to get a sum of $17$, $89$ and $98$. It’s easy enough to work out the number of ways to get each possible sum:
$$\begin{array}{r|rr}
\text{Sum}&0&1&2&3&4&5&6&7&8&9\\
\text{Sum}&18&17&16&15&14&13&12&11&10\\ \hline
\text{Nr. of ways}&1&2&3&4&5&6&7&8&9&10
\end{array}$$
To get a number whose first two digits sum to $6$, say, and whose last two digits also sum to six, you must combine one of the $7$ possible pairs for the first two digits with one of the same $7$ possible pairs for the last two digits. You can do that in $7^2=49$ ways.
Can you finish the calculation from there?
