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
PostgreSQLv16

Qui apparirà il risultato dell'esecuzione del codice

Visible tests
1
Input
[2,4], [6,6]
ExpectedFalse
2
Input
[2,4], [2,7]
ExpectedTrue
3
Input
[2,4], [5,4]
ExpectedTrue
4
Input
[2,2], [0,4]
ExpectedTrue
5
Input
[2,2], [3,1]
ExpectedTrue
6
Input
[2,2], [1,4]
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid