Queen's Line of Attack
In chess, a queen moves along rows, columns, and diagonals, so its attack can be checked with coordinates. The function can_attack receives the white and black queen positions as [row, column] lists on an 8x8 board. Return True if one queen can attack the other in one move, otherwise return False.
Примеры
Ввод
[2, 4], [6, 6]Вывод
FalseВвод
[2, 4], [2, 7]Вывод
TrueВвод
[2, 4], [5, 4]Вывод
TrueНужно реализовать
def can_attack(white: list[int], black: list[int]) -> bool:
Теги
math
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
[2,4], [6,6]Expected
False2
Input
[2,4], [2,7]Expected
True3
Input
[2,4], [5,4]Expected
True4
Input
[2,2], [0,4]Expected
True5
Input
[2,2], [3,1]Expected
True6
Input
[2,2], [1,4]Expected
FalseFocus radio
Paused · SomaFM · Fluid