Skip to content

Commit f2873f0

Browse files
committed
update Iterables and Iterators
1 parent ce10bfa commit f2873f0

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Itertools/IterablesandIterators.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@
55
Author : Ahmedur Rahman Shovon
66
Created : 15 July 2016
77
'''
8-
from itertools import *
9-
8+
from itertools import combinations
109
n = int(input())
11-
s = str(input())
10+
ar = input().split()
1211
k = int(input())
13-
14-
pairs = list(combinations(s.split(),k))
15-
count = 0
16-
17-
for pair in pairs:
18-
if 'a' in pair:
19-
count += 1
20-
21-
print(count/len(pairs))
12+
comb_list = list(combinations(ar,k))
13+
a_list = [e for e in comb_list if 'a' in e]
14+
print(len(a_list) / len(comb_list))

0 commit comments

Comments
 (0)