def find_next_ray(board, object, start, ray):
    """Finds the next instance of {object} in direction {ray} 
    starting from {start} and returns the square of the 
    euclidean distance or -1 if {object} not found"""
    x, y = start

    while True:
        if x < 0 or y < 0 or x >= len(board[0]) or y >= len(board):
            return -1
        if board[y][x] == object:
            return (x-start[0])**2 + (y-start[1])**2
        else:
            x += ray[0]
            y += ray[1]