We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2577c46 commit 94b0816Copy full SHA for 94b0816
Itertools/IterablesandIterators.py
@@ -5,16 +5,17 @@
5
Author : Ahmedur Rahman Shovon
6
Created : 15 July 2016
7
'''
8
-import itertools
+from itertools import *
9
+
10
n = int(input())
-s_ar = input().strip().split()
11
-s = ''.join(s_ar)
+s = str(input())
12
k = int(input())
13
-combination = list(itertools.combinations(s,k))
14
-combination_count = len(combination)
15
-a_count = 0
16
17
-for single_combination in combination:
18
- if 'a' in single_combination:
19
- a_count += 1
20
-print(a_count / combination_count)
+pairs = list(combinations(s.split(),k))
+count = 0
+for pair in pairs:
+ if 'a' in pair:
+ count += 1
21
+print(count/len(pairs))
0 commit comments