Number of four-digit numbers with restrictions. 
How many positive four-digit positive integers are there such that the sum of two of their digits is equal to the sum of the other two?

I let the digits of the four digit positive integer be $a,b,c,$ and $d.$ Then, there are $3$ cases to consider: $$a+b=c+d,a+c=b+d,a+d=b+c.$$ I started by just considering one case, which I considered $a+b=c+d.$ Solving how many four-digit positive integers satisfying this, I used stars-and-bars to get $\binom{20}{3}-\binom{11}{3}-3\cdot\binom{10}{3}=615.$ Then, since there are three cases, I multiplied this by $3$ to obtain $1845$ possible three-digit numbers. However, I think I have overcounted or undercounted some cases. Could anyone tell me if I've done anything wrong? Thanks in advance.
 A: I never know fancy ways to do these problems, but here's my long way:
I get that there are $1584$.
I counted in four cases:
Case 1: all four digits are the same = $9$
Case 2: two pairs = ${10 \choose 2}{4 \choose 2} - 9{3 \choose 1} = 243$
The subtraction is to take away what would be four digits starting with zero.
Case 3: one pair = $228$
Case 4: all digits different = $1104$
For cases 3 & 4, I broke them up into the sums
$$
\begin{align*}
2&: 02 \; 11\\
3&: 03 \; 12\\
4&: 04 \; 13 \; 22\\
5&: 05 \; 14 \; 23\\
&\vdots\\
14&: 59 \; 68 \; 77\\
15&: 69 \; 78\\
16&: 79 \; 88
\end{align*}
$$
Case 3: choose one (matching) pair, and another two with the same sum: $(1+2+3+4+4+3+2+1){4 \choose 2}*2 - 4{3 \choose 1} = 228$
Case 4: all digits different:
$(1+1+3+3+6+6+10+6+6+6+3+3+1)4! - (1+1+2+2+3+3+4)3! = 1104$
Again, the subtractions are taking away what would be four digits starting with zero.
I verified my calculations using the following Python code:
import numpy as np
def anyhalf(v,s):
    ans=0
    cnt=0
    for i in range(len(v)):
        for j in range(i+1,len(v)):
            if 2*(v[i]+v[j])==s:
                cnt+=1
    if cnt>0:
        ans=1
    return ans



count = 0
twopair = 0
onepair = 0
alldiff = 0
for a in range(1,10):
    for b in range(10):
        for c in range(10):
            for d in range(10):
                s = a+b+c+d
                x = anyhalf((a,b,c,d),s)
                if x>0:
                    count += 1
                    if len(np.unique([a,b,c,d]))==4:
                        alldiff += 1
                    if len(np.unique([a,b,c,d]))==3:
                        onepair += 1
                    if len(np.unique([a,b,c,d]))==2:
                        twopair += 1
                    
print(f"count={count}")
print(f"twopair={twopair}")
print(f"onepair={onepair}")
print(f"alldiff={alldiff}")

Which had the following output:
count=1584
twopair=243
onepair=228
alldiff=1104

