human
I am working on the file "04_BFS.ipynb".
The first task is:
Knight Shortest Path

http://www.lintcode.com/en/problem/knight-shortest-path/
Can you write Python code for it?

=====
Can you provide a the Python code you requested?
assistant
#Here is the Python code you requested.

# Definition for a point.
# class Point:
#     def __init__(self, a=0, b=0):
#         self.x = a
#         self.y = b

class Solution:
    # @param {boolean[][]} grid a chessboard included 0 (False) and 1 (True)
    # @param {Point} source a point
    # @param {Point} destination a point
    # @return {int} the shortest path 
    def shortestPath(self, grid, source, destination):
        # Write your code here
        if grid is None or len(grid) == 0 or len(grid[0]) == 0:
            return -1
        
        m, n = len(grid), len(grid[0])
        d = [(1,2), (1,-2), (-1,2), (-1,-2), (2,1), (2,-1), (-2,1), (-2,-1)]
        
        path, step = [[source.x, source.y]], -1

        while path:
            step += 1
            new_path = []
            for x, y in path:
                if [x, y] == [destination.x, destination.y]:
                    return step
                for dx, dy in d:
                    xx, yy = x + dx, y + dy
                    if 0 <= xx < m and 0 <= yy < n and grid[xx][yy] != 1:
                        new_path.append([xx, yy])
                        grid[xx][yy] = 1
            path = new_path
        
        return -1