You are viewing a single comment's thread. Return to all comments →
import itertools N = int(input()) letters = input().split() k = int(input()) listed_combinations = list(itertools.combinations(letters,k))
count = 0
for i in listed_combinations: if "a" in i: count +=1
print(count/len(listed_combinations))
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 →
Enter your code here. Read input from STDIN. Print output to STDOUT
import itertools N = int(input()) letters = input().split() k = int(input()) listed_combinations = list(itertools.combinations(letters,k))
count = 0
for i in listed_combinations: if "a" in i: count +=1
print(count/len(listed_combinations))