mpo_bonbons.py

Created by schraf

Created on March 05, 2022

616 Bytes

Enoncé de l’exercice


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()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.