import random as rd
import numpy as np
import matplotlib.pyplot as plt

## Q1


## Q2


## Q3


## Q5
def partition(population, solution):
    chromosome0 = population[0]
    inf, sup = [], []
    for chromosome in population[1:]:
        if score(chromosome, solution) < ... :
            ...
        else:
            ...
    return inf, chromosome0, sup

def tri_rapide(population, solution):
    N = len(population)
    if N <= 1:
        return ...
    else:
        inf, chromosome0, sup = partition(population, solution)
        return ...

## Q6
def selection(population, solution):
    N = len(population)
    pop_triee = ...
    best = ...
    rest = ...
    return ...

## Q7



## Q8
def mutation(ch, proba_mutation):
    if rd.random() < ... :
        i = ...
        new_car = ...
        return ch[...] + ... + ch[...]
    else:
        return ...

## Q9
def generation(population, solution, proba_mutation):
    taille_pop = len(population)
    enfants = ...
    population_select = selection(population, solution)
    while ... :
        parent1, parent2 = ...
        enfant1, enfant2 = ...
        enfants.append(...)
        enfants.append(...)
    return enfants

## Q10



## Q11
def resolution(solution, proba_mutation=0.2):
    taille_pop = ...
    len_chromosome = ...
    population = ...
    nb_generations = ...
    obtenu, chromosome_solution = trouve_solution(population, solution)
    while not ... :
        population = generation(population, solution, proba_mutation)
        ... = trouve_solution(population, solution)
        nb_generations += ...
        #print(population)
        #print(max([score(ch,solution) for ch in population]))
    return ... , ...

## Q12 - Test
solution = "C'est Incr0yabl& !"

## Q13



## Q15




















