V22.0002 - Python Extra Assignment
The Titan Program
Due: No later than Sunday, August 14th
A NASA space probe has just sent back the first
picture of an alien creature, a Titanian!
Unfortunately, the transmission was garbled, but
the engineers foresaw this possibility,
and programmed the on-board computer to encode
the picture before it was sent. Only
the following three patterns were used to make the picture:
X X X XXX X X X X XThe information has been recorded in the file TITAN2.TXT. (You may also download the simple test cases of BIG_X.TXT, LITTLE_X.TXT, and CORNER.TXT. Note, however, that we might use yet another, different data file of the same format to test your program!)
The second half of the problem involves finding the outline of the creature. As a hint, you might try scanning from the top-left corner until you find the first X, and mark it by changing it to another character (perhaps a Y). Make certain you record the subscripts of the first position. Then, find the first X (or Y) moving clockwise around your present position, starting one position clockwise from where you last moved:
When a new position is found (Hint for
finding the new position), change it to a Y,
make IT the new position, and scan
around it. Stop only when you come back to your
original location, and the scan
around that original position reveals the second
location you found as your next
possible move. (Hint for
setting
up the second array!)
On the printout, display the outline of the
creature, together with its circumference
in Titanian units. (Note that a move
horizontally or vertically is 1 unit, but
diagonally
is sqrt(2) units).
Make certain your program is well commented, and
that it is well structured using
Functions
, etc.