-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththe_even_array.py
More file actions
42 lines (35 loc) · 856 Bytes
/
the_even_array.py
File metadata and controls
42 lines (35 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
The Even Array
Problem Link: https://practice.geeksforgeeks.org/problems/the-even-array/0
Author: Shyam Kumar
Date: 13-09-2019
"""
def the_even_array(s):
auto_next = 0
l = len(s)
count=0
for i in range(l):
if s[i] == 'O' and auto_next == 0:
s=s.replace('O','E',1)
auto_next=1
count+=1
elif s[i] == 'O' and auto_next == 1:
s=s.replace('O','E',1)
auto_next=1
else:
auto_next=0
return count
def main():
t=int(input())
while(t>0):
# Try-except block is only used to remove EOF error
# that comes on online compiler
try:
s=input()
except:
pass
ans = the_even_array(s)
print(ans)
t-=1
if __name__ == "__main__":
main()