Français
Ouvrir dans Telegram

Messageimport random

1 juin 2023
M
import random num_experiments = 10000 streak_count = 0 for _ in range(num_experiments): flips = [] for _ in range(100): flip = random.randint(0, 1) if flip == 0: flips.append('H') else: flips.append('T') has_streak = False for i in range(len(flips) - 5): if flips[i:i+6] == ['H', 'H', 'H', 'H', 'H', 'H'] or flips[i:i+6] == ['T', 'T', 'T', 'T', 'T', 'T']: has_streak = True break if has_streak: streak_count += 1 print(streak_count / 100)

À proximité dans le fil

MMikaelНу так получается, что нам то и списки тут не нужныMMikaelimport random num_experiments = 10000 streak_count = 0 for _ in range(num_experiments): flips = "" for _ in range(100): flip = random.randint(0, 1) if flip == 0
ce message
AAlexander Tменя просто дрожь берет когда string += ‘H’ делается 100 раз 10000 раз, но это не важно, наверное.
ССообщество Python ПрограммистовСообщество Python Программистов@python_scripts · groupe · Technologie
4 169membres43écrivent en 30 jours
Fil de la communauté Ouvrir dans Telegram

Un fil public ouvert issu de l'index de recherche ChatCrawler — « le Google du Telegram public » ; actualisé à mesure que la communauté est explorée. Les heures sont en UTC.

Contenu public uniquement, API officielle de Telegram. À propos · FAQ · Limites de l'index · Retirer une page · Catalogue · Recherche · Comment nous comptons