Contest Math Possible Triangles

In the xy-plane, how many triangles have each of their vertices at points (a,b) where a,b are integers satisfying 1 ≤ a ≤ 5 and 1≤b≤5?

I got twenty-five, but something tells me this isn't right. I set up an inequality, square root of a squared plus b squared is less than a plus b but more than the absolute value of b minus a. Squaring, we can get rid of a squared plus b squared, leaving -2ab<0<2ab, which is always true. So, each pairing works, and we have five times five for twenty-five. I feel that the answer is way too simple. If it is indeed wrong, where did I go wrong?

• It's way too small. If one vertex is at $(1,1)$ and another is at $(2,1)$ then there are 20 choices for the third vertex --- that's 20 triangles right there, with 2 of the vertices fixed. You may have misunderstood the question (or I may have). By the way, what contest is this from? – Gerry Myerson Nov 10 '13 at 5:11
• Why would you consider that inequality at all? It kinda looks like triangle inequality for the triangle with vertices $(0, 0), (a, 0)$ and $(a, b)$. Of course it is true. – Dan Shved Nov 10 '13 at 5:14
• Yeah, I totally misunderstand. I thought it meant the two vertices were on the axes. (What a horrible, embarrassing mistake). This is from the 2010 Fermat II Exam of Pro2Serve at UTK. – Yadnarav3 Nov 10 '13 at 5:15
• Regardless, could someone help me out with the solution process and answer? – Yadnarav3 Nov 10 '13 at 5:16
• Hint: count the ways to choose three distinct points in $\{1,2,3,4,5\}^2$. Subtract the cases where the points are collinear. – mjqxxxx Nov 10 '13 at 5:28

Focus on counting the ways to choose three collinear points. If the line is horizontal or vertical, then there are $5\times{{5}\choose{3}}=50$ possibilities, for a total of $100$ ways. If the slope of the line is $\pm 1$, then there are $9$ ways to place a segment containing three points, $4$ ways to place a segment containing four points (each with $2$ ways to choose the intermediate point), and one way to place a segment containing five points (with $3$ ways to choose the intermediate point), for a total of $40$ ways to choose the points with a slope of $\pm1$. If the slope is $\pm 2$ or $\pm 1/2$, then there are just $3$ ways to place a segment containing three points, for a total of $12$ with these slopes. In total there are $152$ ways to choose three collinear points.
Subtracting this from the total number of ways of choosing three points gives $${{25}\choose{3}}-152=2300 - 152=2148$$ distinct triangles.
• If the first two points you pick are $(1,1)$ and $(2,5)$ then there's no way to pick a third point collinear with those two, so you are getting an underestimate. – Gerry Myerson Nov 10 '13 at 5:40