i) |a-b|=5.
If a > b, the solutions are (6,1), (7,2), ..., (50,45)
That's 45 ways. Those can be reversed since there is an
absolute value.
So also if a > b, the solutions are (1,6), (2,7), ..., (45,50)
That's 45 more ways.
Total: 45+45 = 90 ways.
-----------------------------------------------------
ii) |a-b| < 5
If the smaller of "a" and "b" is n, where 1 ≦ n ≦ 46, then there
are these 4 pairs of distinct numbers from {1,2,...,50}:
{n,n+1}, (n,n+2}, {n,n+3}, {n,n+4}
That's (46)(4) = 184
But for n=47, there are only 3, {47,48}, (47,49}, {47,50},
for n=48, there are only 2, {48,49}, (48,50},
for n=49, there is only 1, {49,50}
Number where a < b 184+3+2+1 = 190.
Those can be reversed, since there is an absolute value. So
the answers where a > b also = 190.
Total: 190 + 190 = 380
Edwin