You are on page 1of 2

10790 - How Many Points Of Intersection?

http://www.questtosolve.com/browse.php?pid=10790
Solved By:

wesley

Theory Difficulty:

easy

Coding Difficulty:

trivial

Algorithms Used:

math

Solution Description:
To get a feel for how the pattern in this problem
works, take the example of four dots in the bottom row, and one dot on top.
Let the dots in the bottom be B1...B4, and the dot on top be A1. There are no
points of intersection.

If we add another dot on top (A2), then the line A2-B1 crosses 3 lines, A2-B2
crosses 2 lines, A2-B3 crosses 1 line, and A2-B4 crosses 0.

If we add A3, then we get 6 intersections, then 4, then 2. Adding A4 gives us


9, then 6, then 3. Look at this pattern:

0
3+2+1
6+4+2
9+6+3
...

Or more explicitly:
0
1 * (3 + 2 + 1)
2 * (3 + 2 + 1)
3 * (3 + 2 + 1)

Note that there is a triangular number sequence going horizontally, and a


triangular number sequence going vertically. This gives us the final result of:

tri(A) * tri(B)
= A(A-1)/2 * B(B-1)/2

You might also like