def numNeighbors(A, r, c):
    """finds the number of neighbors of coordinate r,c in board A"""
    count = 0
    for row in range(r-1, r+2):
        for col in range(c-1, c+2):
            if not(row == r and col == c) and A[row][col] == 1:
                count+=1
    return count