Oct-17-2017, 06:59 PM
I have this code and I want to know if there's a way I can make the 1 multiple numbers (ex: a + 1 or 2 or 3...or 8). I think using a function might help but I don't know how to write it. Here's the problem and what I have.
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.
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.
if a + 1 == c and b + 1 == d or a - 1 == c and b - 1 == d: print("YES") elif a - 1 == c and b + 1 == d or a + 1 == c and b - 1 == d: print("YES") else: print("NO")