This approach uses the area of the triangle formed
by the location of the battleship and the two lower corner point guesses.
Thus, for a ship in the first quadrant, we might have the following situation:
Recall that the area of the triagle is one half the base times the height. In our case, that means that the area of the triangle is
The beauty of this approach is that it is entirely computational. There is no "searching for possible solutions. As long as we are given the distance from the lower left corner to the ship and from the lower right corner to the ship we can just compute the location of the ship. This means that we can construct a program for our calculator that will take the initial information and produce the location of the ship. Below is an annotated program to do exactly this. Note that the program merely walks through the same steps that we took above.
| Figure 1 shows the start of the program. It is now waiting for us to enter the coordinates of the lower left corner. |
|
In Figure 2 we have entered the coordinates of the lower left corner and the distance from that corner to the ship. |
|
In Figure 3 we have entered the coordinates of the lower right corner and the distance from that cornerr to the ship. |
|
The program displays the location of the ship, at point (8,3). It then continues
to try a new problem. For the new problem we will consider the "ocean" to be from (-10,-10) to (10,-10) to (10,10) to (-10,10). Our first guess is the lower left corner, point (-10,-10). The "battleship" game tells us that we are off by 17.0294 units. The we guess the lower right corner, point (10,-10). The game tells us we are off by 3.1623 units. Where is the ship? |
|
For Figure 5 we have given our program the coordinates of the lower left corner, (-10,-10) and the distance, 17.0294, from that point to the ship. |
|
For Figure 6 we have given the program the coordinates of the lower right corner, (10,-10), and the distance from that point to the ship, namely, 3.1623. |
|
The program responds with the location of the ship at (7,-9). |
©Roger M. Palay
Saline, MI 48176
January, 2014