Odpowiedź:
Kod:
import random
def simulate(n_tablets):
result = 0
sim_stat = [0] * n_tablets
i = random.randint(0, n_tablets - 1)
while(not sim_stat[i]):
sim_stat[i] = 1
result += 1
i = random.randint(0, n_tablets - 1)
return result
avrage_result = 0
precission = 100000 #higher better
for _ in range(precission):
avrage_result += simulate(30)
print("Avrage result: {}".format(avrage_result / precission))
Info:
Gdybyś potrzebował informacji jak i dlaczego to działa pytaj, chętnie opiszę więcej szczegółów w komentarzach :).