You are viewing a single comment's thread. Return to all comments →
from itertools import combinations def probability(letter, K): final = list(combinations(letter,K)) count = 0 for i in range(len(final)): if 'a' in final[i]: count += 1 prob = count/len(final) return prob if __name__ == "__main__": N = int(input()) letter = list(input().split()) K = int(input()) result = probability(letter,K) print(result)
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 →