import random


def rouletteWheelSelectionId(fitness, sumFitness, nChromosomes): 
    """    
    A roulette Wheel Selection mechanism for selecting a chromosome
    
    Parameters
    ---------- 
    fitness : list
        The list of fitness values for each chromosome
    sumFitness : float
        The summation of all the fitness values for all chromosomes in a generation
    nChromosomes: int
        Number of chrmosome in a population
          
    Returns
    -------
    id
        chromosomeId: The id of the chromosome selected
    """
    pick    = random.uniform(0, sumFitness)
    current = 0
    for chromosomeId in range(nChromosomes):
        current += fitness[chromosomeId]
        if current > pick:
            return chromosomeId