/*I have submitted almost 20 times , still I’m not getting , I’m little confident that my answer is //correct but I don’t know on which test case my solution is wrong , please help me, please ,I’m /*new here
I have also done what you are saying but still not getting the answer ,Could you please find few test cases where my answer could be wrong ? Why I feel like my solution is right on every test cases
@anon4198588
Test case : 12
PPAPPPPPPPPP
Ur code gives 1. Required answer 0. If A is present at position 2, proxy becomes at least 1, even when not required.
I too am passing all testcases I have created.I have checked other correct solutions,but I still cannot find where am I going wrong.Can someone please suggest a testcase where my code would not work.
import sys
T = int(input()) # No. of testcases
def proxydays(s, S):
"""
Input: The attendance string and its size
Output: Required no. of days to get 75% attendance
"""
act = float(S.count('P'))/float(s)
if (act < 0.75):
req = int((0.75-act)*s) + 1
return(req)
else:
return(0)
def proxymaker(s, A):
"""
Input: Att. string, its size, required no. of days
Output: No. of possible proxies
"""
p_days = 0
for i in range(2, s-2):
con1 = False
con2 = False
con3 = False
if (A[i] == 'A'):
con1 = True
if (A[i-1] == 'P') or (A[i-2] == 'P'):
con2 = True
if (A[i+1] == 'P') or (A[i+2] == 'P'):
con3 = True
if (con1 and (con2 and con3)):
p_days += 1
return(p_days)
while T:
s = int(input())
S = input()
req_days = proxydays(s, S)
proxy_days = proxymaker(s, S)
if (req_days > 0):
if (proxy_days >= req_days):
print(req_days)
else:
print("-1")
else:
print("0")
T -= 1