From 8e3ff40c59e42663c1d8c839044fe7a2b3b720a8 Mon Sep 17 00:00:00 2001 From: Neumark1982 <54577016+Neumark1982@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:19:55 +0300 Subject: [PATCH] Update 03_hw.md --- Module2/home_work/03_hw.md | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Module2/home_work/03_hw.md b/Module2/home_work/03_hw.md index 41a45c3..8bd02db 100644 --- a/Module2/home_work/03_hw.md +++ b/Module2/home_work/03_hw.md @@ -20,9 +20,39 @@ ### Решение задачи -```python -# TODO: you code here... -``` +from random import randint + +square_one_coordinate = [randint(1, 8), randint(1,8)] +square_two_coordinate = [randint(1, 8), randint(1, 8)] + +print('Координаты первой клетки', square_one_coordinate) +print('Координаты второй клетки', square_two_coordinate) + +if square_one_coordinate[0] %2 == 0 and square_one_coordinate[1] % 2 == 0: + color_of_first_square = 'white' +else: + color_of_first_square = 'black' + +if square_one_coordinate[0] %2 != 0 and (square_one_coordinate[0] + square_one_coordinate[1]) % 2 == 0: + color_of_first_square = 'white' +else: + color_of_first_square = 'black' + +if square_two_coordinate[0] %2 == 0 and square_one_coordinate[1] % 2 == 0: + color_of_second_square = 'white' +else: + color_of_second_square = 'black' + +if square_two_coordinate[0] %2 != 0 and (square_one_coordinate[0] + square_one_coordinate[1]) % 2 == 0: + color_of_second_square = 'white' +else: + color_of_second_square = 'black' + + +if color_of_first_square == color_of_second_square: + print('Да') +else: + print('Нет') ---