Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
def is_valid_battleship_board(board):
    def is_ship(cell):
        return cell == '#'

    def is_valid_ship(ship):
        if ship.count('#') not in [1, 2, 3, 4]:
...             return False
...         if '#' in ship and '.' in ship:
...             return False
...         return True
... 
...     def check_ships(board):
...         for row in board:
...             for i in range(len(row)):
...                 if is_ship(row[i]):
...                     ship = [row[i]]
...                     if i < len(row) - 1:
...                         j = i + 1
...                         while j < len(row) and is_ship(row[j]):
...                             ship.append(row[j])
...                             j += 1
...                     if not is_valid_ship(ship):
...                         return False
...         return True
... 
...     if not all(len(row) == 10 for row in board):
...         return False
... 
...     if not check_ships(board):
...         return False
... 
...     for i in range(len(board[0])):
...         column = [row[i] for row in board]
...         if not check_ships([column]):
...             return False
... 
...     return True
... 
... # Считываем поле из входных данных
... field = [list(input()) for _ in range(10)]
... 
... # Проверяем корректность расстановки кораблей и выводим результат
... if is_valid_battleship_board(field):
...     print("YES")
... else:
