Iterables and Iterators

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from itertools import combinations
    
    
    if __name__ == '__main__':
        n = int(input().rstrip())
        letters = input().rstrip().split()
        k = int(input().rstrip())
        combs = list(combinations(letters, k))
        num_of_a = 0
        for c in combs:
            if 'a' in c:
                num_of_a += 1
        print(round(num_of_a / len(combs), 12))