General description: Your program will read data from a data le that:
contains at most 50 lines;
contains at most 81 characters per line, including the ending new line character;
contains only *s, simple spaces and new line characters.
If the name of the data le is data.txt then your program will be run as a.out <data.txt, so that
you will read the input as if it was coming from the keyboard. What is represented in the data le is
between 1 and 5 pieces of a possibly incomplete tile. The tile is fragmented if the number of pieces
is greater than 1. Four examples of data les are provided: data1.txt, data2.txt, data3.txt
and data4.txt.
Note that what has been represented above is the reconstructed tiles, not what is stored in the
data les, which you should examine while reading this.
Every piece is a polygon whose edges have four possible orientations. You can make the following
assumptions on what is represented in the data le (some assumptions are relevant to only some
of the questions).
The tile has square corners and is not rotated (it has vertical and horizontal edges).
The orientation of the pieces w.r.t. the tile is correct: the pieces are neither inverted nor
rotated.
If pairs of consecutive *s on a common horizontal edge of a piece are stored in columns c1
and c2 , then jc1 c2j = 2.
If pairs of consecutive *s on a common vertical edge of a piece are stored in rows r1 and r2,
then jr1 r2j = 1.
If pairs of consecutive *s on a common diagonal edge of a piece are stored in rows r1 and r2
and in columns c1 and c2 , then jr1 r2j = 1 and jc1 c2j = 1.
No piece contains any hole.
Say that a * stored in row r1 and column c1 is a neighbouring * of a * stored in row r2 and
column c2 if either c1 = c2 and jr1 r2j = 1, or r1 = r2 and jc1 c2j = 2, or jr1 r2j = 1
and jc1 c2j = 1. The vertices of a given piece can be identied as those points marked
with a * from which it is possible to reach neighbouring *s in exactly two derent directions
and in no opposite direction.
Each corner of the tile is intact and preserved.
If a piece can match a corner of the tile, then that piece matches that corner of the tile.
Questions
Q1 Determine whether the tile in the data le is nonfragmented and complete. For this question,
the answer will be either
The tile is intact
or
The tile is not intact
If the tile is intact then no further output will be produced
Q2 Determine the total number of edges of all pieces. For this question, the answer will be of the
form
There is a total of ... edges
Q3 Determine the number of pieces, as well as the number of edges of the piece with the least
number of edges, and the number of edges of the piece with the greatest number of edges.
For this question, the answer will be of the form
There is a unique piece, having ... edges
or
There is a total of ... pieces, that all have ... edges
or
There is a total of ... pieces, that have between ... and ... edges
Q4 Determine whether the tile is complete. For this question, the answer will be either
The tile is complete
or
The tile is incomplete
Sample outputs
$ a.out <data1.txt
The tile is intact
$ a.out <data2.txt
The tile is not intact
There is a total of 7 edges
There is a unique piece, having 7 edges
The tile is incomplete
$ a.out <data3.txt
The tile is not intact
There is a total of 35 edges
There is a total of 4 pieces, that have between 7 and 11 edges
The tile is complete
$ a.out <data4.txt
The tile is not intact
There is a total of 43 edges
There is a total of 4 pieces, that have between 5 and 14 edges
The tile is incomplete