Share your repls and programming experiences

← Back to all posts
Python: Bishop move
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
kmno4
ClaireCheung723
Sandytl
adugyamfi1
ADITYAJOSHI3
Wolf_Queen
124_23_Huang_Ya
junhooo111
pole55
Comments
hotnewtop
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")