Iterables and Iterators

  • + 0 comments
    from itertools import combinations
    
    #total possible outcome
    N = int(input())
    
    #list of outcomes
    l = list(input().split())
    
    #desired outcome
    n = int(input())
    
    new = list(combinations(l, n))
    
    count = 0
    
    #calculation for the probability of 'a' being in the strings given
    for i in new:
        if 'a' in i:
            count += 1
    
    
    print(f"{count/len(new):.12f}")