def value(A):
    """
    The heuristic for the 8Queen problem is this:
    h(A) = number of attack that the queens have between each
    other.
    The data structure representation for the chessboard
    will be a list of tuples each of them representing the
    coordinates of a the position of a queen.

    Complexity: O(N^2)
    """
    N = len(A)
    h=0
    for i in range(N-1):
        for j in range(i+1, N):
            q1 = A[i]
            q2 = A[j]
            if q1[0] == q2[0]:
                h+=1
            elif q1[1] == q2[1]:
                h+=1
            elif q1[0]+q1[1] == q2[0]+q2[1]:
                h+=1
            elif q1[0]-q1[1] == q2[0]-q2[1]:
                h+=1

    return h

    The heuristic for the 8Queen problem is this:
    h(A) = number of attack that the queens have between each
    other.
    The data structure representation for the chessboard
    will be a list of tuples each of them representing the
    coordinates of a the position of a queen.

    Complexity: O(N^2)
    
recipes/Python/578157_Hill_Climbing_Template_Method/recipe-578157.py