Work out a program, that performs subsequently the following tasks:
a) Writing into the computer memory coordinates of n points, A_1, A_2, ..., A_n, (n >= 1) given in the plane.
b) Rendering on the computer screen the visible part of a piecewise line F composed of straight line segments subsequently connecting A_1, A_2, ..., A_n. If some point A_i is not within the domain of the computer screen, then line segments A_(i-1)A_i and A_iA_(i+1) should not be dispayed.
c) Execution of the subroutines described in items a) and b).
Let us consider a rectangle P with sides parallel to the coordinate axes. The rectangle P is specifyed by coordinates of its vertices.
a) Find out whether the figure F (from the problem 1) can be completely placed within the rectangle P after applying appropriate moves described in problem 3.
b) Find out whether there exists at least one set of 4 subsequent points, A_i, A_(i+1), A_(i+2), A_(i+3), (i=1, 2, 3, ..., n) from among the above given points, which are vertices of a right trapezoid (i.e. four-sided figure having two sides parallel and a right angle).
Realize by a subroutine the moves of the figure F, which transfer it toward any one of the four main directions: upwards, downwards, leftwards and rightwards. Each move must be started by pressing a designated key on the computer keyboard. Have in mind, that during the process of movement, some parts of F may become invisible, whereas some other parts may come into the field of vision.
Source: Obuchenieto po matematika, journal published by Bulgarian Ministry
of Education, n. 3, 1987, p. 61.
© The text is translated from Bulgarian by Emil Kelevedzhiev (firstname.lastname@example.org)
Return to the Home Page of Bulgarian Mathematics and Informatics Competitions.