Number of lines determined given a set of points Consider the following set of points in the $x-y$ plane:
$$A=\{ (a,b)|a,b \in \mathbb{Z} \ and \ |a|+|b|\le 2\}$$
How to find the number of straight lines which pass through at least 2 points in $A$?
One line is determined by 2 distinct points. To find the number of lines one is to choose any 2 points and find the possible combinations. The counting is easy if any 3 points are non-collinear, or only small number of points are collinear and the collinear points are non-collinear to the others. But there are a total of 13 points in the set, which gets complicated(at least for me) when there are different subsets of $A$ which consist of collinear points. Considering separate cases don't help much either. 
Is there any way to count the number of lines determined by the points in the set above? And how should one find the number of lines determined when given larger size of set of points? Can anyone provide any hint and guidance? Thanks in advance.
The answer is 40 lines.

There are $13$ points in total which consists of $2$ subsets of $5$ collinear points and $10$ subsets of $3$ collinear points.
Number of ways choosing any $2$ from $13$ points $={13 \choose 2}$
Number of extra lines in the 2 subsets of $5$ collinear points $= 2({5 \choose 2}-1)$
Number of extra lines in the 10 subsets of $10$ collinear points $= 10({3 \choose 2}-1)$
Thus the number of lines are ${13 \choose 2}-2({5 \choose 2}-1)-10({3 \choose 2}-1)=40$
All credits to AoPS member $mavropnevma$ 
