You are viewing a single comment's thread. Return to all comments →
from itertools import combinations
length = int(input()) non_a = length - input().count("a") draws = int(input())
def combo_nbr(pool, draws): return len(list(combinations(range(pool), draws)))
non_a_chance = combo_nbr(non_a, draws) / combo_nbr(length, draws) print(1 - non_a_chance)
Seems like cookies are disabled on this browser, please enable them to open this website
Iterables and Iterators
You are viewing a single comment's thread. Return to all comments →
from itertools import combinations
length = int(input()) non_a = length - input().count("a") draws = int(input())
def combo_nbr(pool, draws): return len(list(combinations(range(pool), draws)))
non_a_chance = combo_nbr(non_a, draws) / combo_nbr(length, draws) print(1 - non_a_chance)