Skip to content

Instantly share code, notes, and snippets.

@litiblue
Created August 8, 2014 12:40
Show Gist options
  • Select an option

  • Save litiblue/03e635056c21fdd4a460 to your computer and use it in GitHub Desktop.

Select an option

Save litiblue/03e635056c21fdd4a460 to your computer and use it in GitHub Desktop.

Revisions

  1. litiblue created this gist Aug 8, 2014.
    13 changes: 13 additions & 0 deletions BishopMove.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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