Triangular Vertices
Consider the points on an infinite grid of equilateral triangles as shown
below:
x
x x
x x x
x x x x
x x x x x
.
.
Note that if we number the points from left to right and top to bottom,
then groups of these points form the vertices of certain geometric shapes. For
example, the sets of points {1,2,3} and {7,9,18} are the vertices of
triangles, the sets {11,13,26,24} and {2,7,9,18} are the vertices of
parallelograms, and the sets {4,5,9,13,12,7} and {8,10,17,21,32,34} are the
vertices of hexagons.
Write a program which will repeatedly accept a set of points on this
triangular grid, analyze it, and determine whether the points are the vertices
of one of the following acceptable figures: triangle, parallelogram, or
hexagon. In order for a figure to be acceptable, it must meet the following
two conditions:
1) Each side of the figure must coincide with an edge in the grid.
and 2) All sides of the figure must be of the same length.
0 comments:
Post a Comment
Your Suggestions and Reviews are valuable to us to make this blog better........