I'm working on a project where I'm programming a battleship game using objected-oriented principles of programming.
I got stuck at one problem that is purely mathematical and relates to the positioning of the battleships. I would like to ask you for an equation to help me out. Let get straight to the point:

- I have converted a A2, G8, I9 notation into a lineta system with (
x+1 + y*10) (xandystarting from 0) so that each mast has its numerical position (from 1 to 100). - Lets take the ship in the top-left corner as an example. It occupies positions 1 and 2 on the board.
- In this case squares that cannot accept any battleships are: 3, 11, 12 (ships cannot touch one another)
Problem: What is the equation that would tell me what squares cannot accept any masts given the position of an already set mast?
Rules: 1. Ships cannot touch one another, 2. Masts of of a battleship can only be positioned along one another' sides - not diagonally.