Problem C
Find the Battleship

The game of Battleship is played on a 10x10 area of squares in which rows are designated A through J and columns are designated 1 through 10. The object of the game is to locate the enemy battleship which occupies four consecutive squares along one row or along one column. To locate the battleship, test "shots" are directed at squares throughout the playing area.

Write a program that reads in the list of test "shots" (all of which are misses), examines the playing area, and reports on ALL possible locations for the battleship (assuming no shots hit). Each "shot" is on a separate line in the form row column for example, D 3 or H 10 To keep the input simple, the test "shots" have been collected in a file called battle1.dat. The program should report each occurrence of four or more consecutive horizontal or vertical squares as a possible location of the battleship. Report each such area only once; e.g., an entirely blank row is just one possible location. The message should have the form:

Between rc1 and rc2		or		Between r1c and r2c

where r is a row letter, c is a column number, and subscripted rows/columns are different. As an example, the following list of missed "shots" in the battle1.dat file should cause your program to produce a report like the one at the right.

A 4
A 7
A 9
B 3
B 7
C 1
C 4
C 8
C 10
D 5
D 6
D 8
E 2
E 6
F 1
F 3
F 6
F 10
G 3
G 5
G 8
H 1
H 9
H 10
I 4
I 7
J 3
J 6

Although the "shots" for this sample are in order by rows, and, within a row, in order by columns, you should not assume that "shots" will always be in such an order. Following is a report for all the possible battleship locations for this game.

Between D1 and D4
Between E7 and E10
Between H2 and H8
Between J7 and J10
Between A2 and D2
Between F2 and J2
Between D4 and H4
Between C7 and H7
Between B9 and G9