Skip to content
Sign upLog in
← Back to Community

Python: Bishop move

Profile icon
pole55

Chess bishop moves diagonally in any number of squares. Given two different squares of the chessboard, determine whether a bishop can go from the first square to the second one in a single move.

The program receives four numbers from 1 to 8 each specifying the column and the row number, first two - for the first square, and the last two - for the second square. The program should output YES if a bishop can go from the first square to the second one in a single move or NO otherwise.

Voters
Profile icon
VIKASHKUMAR86
Profile icon
VicenteValencia
Profile icon
asthaberi8
Profile icon
stefH92
Profile icon
kmno4
Profile icon
ClaireCheung723
Profile icon
Sandytl
Profile icon
adugyamfi1
Profile icon
ADITYAJOSHI3
Profile icon
Wolf_Queen
Comments
hotnewtop
Profile icon
BillSara

num1 = int(input())
num2 = int(input())
num3 = int(input())
num4 = int(input())

if num1+num2 == num3+num4 or num2-num1==num4-num3 :
print("YES")
else:print("NO")