def queens_fitness(genome):
 fitness = 0
 for check_queen_col in range(len(genome)):
  is_attacked = 0
  for other_queen_col in range(len(genome)):
   if (check_queen_col != other_queen_col):
    check_queen_row = int(genome[check_queen_col])
    other_queen_row = int(genome[other_queen_col])
    if (check_queen_row == other_queen_row):
     is_attacked = 1
     break
    elif (abs((check_queen_row - other_queen_row)) == abs((check_queen_col - other_queen_col))):
     is_attacked = 1
     break
  if (not is_attacked):
   fitness += 1
 return fitness

def queens_fitness ( genome ) : fitness = 0 for check_queen_col in range ( len ( genome ) ) : is_attacked = 0 for other_queen_col in range ( len ( genome ) ) : if ( check_queen_col != other_queen_col ) : check_queen_row = int ( genome [ check_queen_col ] ) other_queen_row = int ( genome [ other_queen_col ] ) if ( check_queen_row == other_queen_row ) : is_attacked = 1 break elif ( abs ( ( check_queen_row - other_queen_row ) ) == abs ( ( check_queen_col - other_queen_col ) ) ) : is_attacked = 1 break if ( not is_attacked ) : fitness += 1 return fitness
calculate the fitness of an organization of queens on the chessboard .