+ 4

Battleship

"Battleship" game. Danabek plays in "Battleship" game. Field of the game is always a square with 10x10 cells. Cells that have been already fired are marked. However, Danabek did not fired any enemy ship yet. Your task is to determine the maximum length of a ship that can fit into unfired cells. The ship is a rectangle size with 1 cell width and can be placed horizontally or vertically. (It is guaranteed that the game field has at least one unfired cell). Input Inputed 10 rows that consist ouf of 10 values each, the numbers are separated by one white space. Number 1 means that the cell is fired, number 0 - that the cell is not fired yet. Output Output number between 1 and 10 - the maximum length of the ship that can be placed into unfired cells. Samples: Input 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 Output: 9 https://code.sololearn.com/cv8xGX0Xuk2P/?r

18th Oct 2021, 7:58 AM
Le.7
4 Antworten
+ 3
Le.Jus Do you have any problem or what?
18th Oct 2021, 8:02 AM
A͢J
A͢J - avatar
+ 3
My code don't work. I don't understand
18th Oct 2021, 8:22 AM
Le.7
+ 2
You had a logical issue with the counter reset. You don't need a array with the maximum value for each row. Your code does only check the rows (horizontally), so you need a second set of loops for the columes (vertically). Here I've done some adjustmends. It works now for the rows. Try to do the columes. https://code.sololearn.com/c7VlltAa82l3/?ref=app
18th Oct 2021, 9:36 AM
Coding Cat
Coding Cat - avatar
0
Thanks
18th Oct 2021, 12:56 PM
Le.7