CS4HS Summer Program for HS Teachers
July 2011
Problem 3
Triangles in a grid

Two triangles are congruent if they have the same shape and size. In other words, they are congruent if, and only if, one can be transformed into the other by a combination of translations, rotations and reflections.

The input file DATA3.txt will contain 5 lines, each line having 4 integers, separated by a single space, 0 <= A B X Y <= 8, where (A,B) specifies the bottom left corner of a rectangle, and (X,Y) specifies the top right corner of a rectangle in the cartesian plane.

The output file OUT3.txt will contain 5 lines. Each line contains the number of different (not congruent) triangles contained in the rectangle. Only consider triangles with integer coordinates inside the grid specified by (A,B) and (X,Y).

Sample Input (only first 2 shown):
0 0 3 5
2 3 8 6
Sample Output (only first 2 shown):