My issue
Explain last line print((count2-count1)//2-1) please
T=int(input())
for _ in range(T):
i=int(input())
chef=input()
other=input()
count1=0
count2=0
count=0
for j in range(i):
if(chef[j]==other[j]):
count+=1
elif((chef[j]==“R” and other[j]==“S”) or (chef[j]==“P” and other[j]==“R”) or (chef[j]==“S” and other[j]==“P”)):
count1+=1
else:
count2+=1
if(count2<count1):
print(0)
elif(count1==count2):
print(1)
else:
print((count2-count1)//2-1)
My code
T=int(input())
for _ in range(T):
i=int(input())
chef=input()
other=input()
count1=0
count2=0
count=0
for j in range(i):
if(chef[j]==other[j]):
count+=1
elif((chef[j]=="R" and other[j]=="S") or (chef[j]=="P" and other[j]=="R") or (chef[j]=="S" and other[j]=="P")):
count1+=1
else:
count2+=1
if(count2<count1):
print(0)
elif(count1==count2):
print(1)
else:
print((count2-count1)//2-1)
Problem Link: PASCRO Problem - CodeChef