DailyProjects
پاسخنظرسنجیfrom random import shuffle
from collections import Counter
def calc():
lst = [1, 1, 1, 2, 2, 2, 3, 3, 3]
shuffle(lst)
partitions = [lst[i : i + 3] for i in range(0, len(lst), 3)]
return all(len(set(sub)) == 3 for sub in partitions)
n = 100_000
c = Counter(calc() for _ in range(n))
print(round(c[True] / n, 2))
@AmirSoroushh
10 · 3.4K ·