Iterables and Iterators

  • + 0 comments
    from itertools import *
    r, x, l = int(input()), input().split(), int(input())
    p = [i+1 for i in range(len(x)) if x[i] == 'a']
    m = list(combinations(range(1,r+1),l))
    seen = 0
    for i in range(len(m)):
        for pair in m:
            for num in p:
                if num in pair:
                        seen += 1
                        break
        break
    print(round(seen/len(m), 4))``