https://www.codechef.com/LRNDSA02/problems/PSHOT

what is the problem with my code and how do I format my code in the discussion forum

MY answer link: CodeChef: Practical coding for everyone

import math
for _ in range(int(input())):
    n=int(input())
    l1=input()
    (a,b,c,i)=(0,0,2*n,0)
    while abs(a-b)<=math.ceil(c/2) and i<len(l1):
        if i%2==0 and l1[i]=='1':
            a+=1
        elif i%2!=0 and l1[i]=='1':
            b+=1
        i+=1
        c-=1
    print(i)
1 Like

Tutorial to format your code

2 Likes

NOT WORKING

You’re using single quotes ('), not backticks (`).

2 Likes