Queens

Report a typo

Given are the coordinates of two queens on a chessboard. Find out whether they take each other. Taking in chess means attacking. The queen moves any number of vacant squares horizontally, vertically, or diagonally.

chessboard with two queens

Input data format

Four integer numbers x1,y1,x2,y2 x_1, y_1, x_2, y_2 .

Output data format

Type "YES" (uppercase) if they take each other and "NO" if they don't.

You may need to calculate the absolute value of the number. You can do it this way:

import kotlin.math.*

println(abs(-5)) // 5

Sample Input 1:

1 1
3 3

Sample Output 1:

YES

Sample Input 2:

1 1
4 3

Sample Output 2:

NO

Sample Input 3:

2 2
5 2

Sample Output 3:

YES
Write a program in Kotlin
fun main() {
// write your code here
}
___

Create a free account to access the full topic