def fitness(ch,distance,shift):
    """Function calculates the fitness of a chromosome 'ch'"""
    countryNo=len(ch)
    total = 0.
    for c in range(countryNo):
        total += distance[ch[c]][ch[(c+1)%countryNo]]
    if shift - total < 0:
        return 0
    else:
        return shift - total