more effective version of battleship1p problem