from math import ceil from kandinsky import fill_rect from random import randint def affiche(l,c): m = max(c) # maxi bonbons parmi les enfants for (i,v) in enumerate(c): coul = int(255 * v / m) # variation de la couleur rouge fill_rect(2*i, l, 2, 1, (coul,0,0)) # rectangle 2*1 pixels def MPO106(): t = 0 Bo = [0 if k%4 == 0 else randint(1,200) for k in range(160)] # initialisation repartition while max(Bo) != min(Bo): Bo = [ceil(b/2) + ceil(Bo[k-1]/2) for (k,b) in enumerate(Bo)] affiche(t, Bo) t += 1 return Bo[0] MPO106()