You are viewing a single comment's thread. Return to all comments →
from itertools import combinations
N, S, K = int(input()), list(input().split()), int(input())
S=''.join(S) combs = list(combinations(S, K)) tups = [p for p in combs if 'a' in p] print(round(len(tups)/len(combs),3))
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
N, S, K = int(input()), list(input().split()), int(input())
S=''.join(S) combs = list(combinations(S, K)) tups = [p for p in combs if 'a' in p] print(round(len(tups)/len(combs),3))