2016-수학-B형-홀수-8¶
문제¶
풀이¶
from sympy import Rational
from itertools import product
all_possibilities = list(product("HT", repeat=5))
count = 0
for event in all_possibilities:
num_heads = sum(1 for i in event if i == "H")
num_tails = 5-num_heads
if num_heads*num_tails ==6 :
print(["found!",event])
count +=1
Rational(count,len(all_possibilities))
['found!', ('H', 'H', 'H', 'T', 'T')]
['found!', ('H', 'H', 'T', 'H', 'T')]
['found!', ('H', 'H', 'T', 'T', 'H')]
['found!', ('H', 'H', 'T', 'T', 'T')]
['found!', ('H', 'T', 'H', 'H', 'T')]
['found!', ('H', 'T', 'H', 'T', 'H')]
['found!', ('H', 'T', 'H', 'T', 'T')]
['found!', ('H', 'T', 'T', 'H', 'H')]
['found!', ('H', 'T', 'T', 'H', 'T')]
['found!', ('H', 'T', 'T', 'T', 'H')]
['found!', ('T', 'H', 'H', 'H', 'T')]
['found!', ('T', 'H', 'H', 'T', 'H')]
['found!', ('T', 'H', 'H', 'T', 'T')]
['found!', ('T', 'H', 'T', 'H', 'H')]
['found!', ('T', 'H', 'T', 'H', 'T')]
['found!', ('T', 'H', 'T', 'T', 'H')]
['found!', ('T', 'T', 'H', 'H', 'H')]
['found!', ('T', 'T', 'H', 'H', 'T')]
['found!', ('T', 'T', 'H', 'T', 'H')]
['found!', ('T', 'T', 'T', 'H', 'H')]
\[\displaystyle \frac{5}{8}\]