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      X
The 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 file is in ASCII format, with up to 79 columns per row, and up to 24 rows. You will need to recognize one line at a time and the end of the file. After reading your two eimension list (aka, array), print it out on the screen in its original state. Next, filter the picture, taking out all X’s which are not part of one of the three valid patterns. (Note that a single X may be part of more than one pattern.) Display the resultant picture on the screen, with the area of the creature in Titanian units (i.e., the count of the X’s left after filtering). Note: Allow either upper case (X) or lower case (x) X’s.

Hint: Get the first half completly running before attempting the second half!

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.