# INPUT: # The input consists of 3 lines. The first line contains the integer N, denoting the length of the list. The next line consists of N space-separated lowercase English letters, denoting the elements of the list. The third and the last line of input contains the integer K, denoting the number of indices to be selected. # OUTPUT: # Output a single line consisting of the probability that at least one of the indices selected contains the letter 'b' # example: for input as ['b', 'b', 'c', 'd'], output should be 0.8333 from itertools import combinations N = int (input()) #print (N) L = input().split() # print(L) K = int(input()) C = list(combinations(L,K)) F = filter (lambda c : 'b' in c, C) print('{0: .3}'.format(len(list(F))/len(C)))
@ipvikas2 жыл бұрын
Thanks a lot!!!
@navneetsinghtaneja50022 жыл бұрын
Easy question, but one question ye hain mind main ki jab tak detail vala question nhi samjha tha tab tak samajh ni aya tha kya karna hain
@KaushalKumar-ic8qj2 жыл бұрын
What I get from question...indices means index which was 'to be selected' in the third line. Could you please explain why and how did you get to know that it would be in pairs and you decided to use tuple for that. The solution is easy, but I want to understand third point of the question more...If you could explain more..Thanks in advance.
@CloudyML2 жыл бұрын
It's given 2 in 3rd line, 2 here means pair of 2. Then we decided to use tuple. Sometimes you need to read question multiple times to understand what they are asking. Sorry for the late reply, I got this comment while cross checking, since We did not get notification.