You are viewing a single comment's thread. Return to all comments →
from itertools import combinations fruitless = int(input()) letters = input().split() indcies = int(input()) combos = sum(1 for i in combinations(letters, indcies)) combo_with_A = sum(1 for c in combinations(letters, indcies) if "a" in c) probability = combo_with_A / combos print(f"{probability:.3f}")
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 →