We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Iterables and Iterators
Iterables and Iterators
Sort by
recency
|
893 Discussions
|
Please Login in order to post a comment
from itertools import combinations n=int(input()) a=list(input().split()) k=int(input()) b=list(combinations(a,k)) count=sum(1 for x in b if 'a' in x) print(count/len(b))
from itertools import combinations n=int(input()) y=input().split() f=int(input()) c=list(combinations(y,f)) d=0 for i in c: if "a" in i: d+=1 print(d/len(c))
For coders who want to challenge yourself don't use itertools lib Using The Recursion :D