mpo_bonbons2.py

Created by schraf

Created on March 06, 2022

830 Bytes


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]

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.