You are viewing a single comment's thread. Return to all comments →
from itertools import * inp=int(input()) inp2=input().split() inp3=int(input())
list1=list(combinations(inp2, inp3)) list1.sort() sorted_list=[] for j in list1: z=''.join(list(j)) sorted_list.append(z)
count=0 for x in sorted_list: if "a" in x: count+=1
print(count/len(list1))
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 * inp=int(input()) inp2=input().split() inp3=int(input())
list1=list(combinations(inp2, inp3)) list1.sort() sorted_list=[] for j in list1: z=''.join(list(j)) sorted_list.append(z)
count=0 for x in sorted_list: if "a" in x: count+=1
print(count/len(list1))