Created
August 8, 2014 12:40
-
-
Save litiblue/03e635056c21fdd4a460 to your computer and use it in GitHub Desktop.
BishopMove
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BishopMove(object): | |
| def howManyMoves(self, r1, c1, r2, c2): | |
| if (r1 + c1) % 2 != (r2 + c2) % 2: | |
| res = -1 | |
| else: | |
| res = 2 | |
| if r1 + c1 == r2 + c2: | |
| res -= 1 | |
| if r1 - c1 == r2 - c2: | |
| res -= 1 | |
| return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment