From 45cf0686bd3c1ef2194e6b5ce20810f9db212a48 Mon Sep 17 00:00:00 2001 From: ehermakov Date: Sun, 3 Dec 2023 23:44:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B0?= =?UTF-8?q?=D1=8E=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B4=D0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HNS/Excercises/ShipCraft/main.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/HNS/Excercises/ShipCraft/main.py b/HNS/Excercises/ShipCraft/main.py index c98e1d6..c74ff48 100644 --- a/HNS/Excercises/ShipCraft/main.py +++ b/HNS/Excercises/ShipCraft/main.py @@ -120,15 +120,21 @@ def check_possible(field, row, col): # Здесь мы знаем, что корабль помещается на поле. if field_size - row >= ship_size: # Теперь нужно проверить, не заблокировано ли какое-то из полей, - for i in range(row, row + ship_size): - if check_blocked(field, row, col): - return True + for r in range(row, row + ship_size): + if not check_blocked(field, r, col): + return False + return True + + return False + if ship_direction == 1: if field_size - col >= ship_size: - for i in range(col, col + ship_size): - if check_blocked(field, row, col): - return True + for c in range(col, col + ship_size): + if not check_blocked(field, row, c): + return False + return True + return False