from math import ceil,cos,sin,pi from kandinsky import fill_rect,draw_string from random import randint from time import sleep def affiche(l,c): m = max(c) # maxi bonbons parmi les enfants n = len(c) for (i,v) in enumerate(c): coul = int(255 * v / m) # variation de la couleur rouge x, y = 160 + int(100 * cos(2 * i * pi / n)), 110 + int(-100 * sin(2 * i * pi / n)) fill_rect(x, y, 4, 4, (coul,0,0)) # rectangle 2*1 pixels- def MPO106(n): t = 0 Bo = [0 for k in range(80)] Bo[0] = n while max(Bo) != min(Bo): Bo = [ceil(b/2) + ceil(Bo[k-1]/2) for (k,b) in enumerate(Bo)] affiche(t, Bo) draw_string(str(t)+" ",140,100) draw_string(str(min(Bo))+" - "+str(max(Bo)),140,130) sleep(.1) t += 1 return Bo[0]