PLZZ HELP ME SOMEONE WITH THE TEST CASES OF DUCK GAME
DONT KNOW WHY ITS GIVING WRONG ANS,I HAVE CHECKED MYSELF WITH CUSTOM INPUTS ITS GIVING RIGHT RESULT.
Here is my code.
def solve(a,b):
length_b=len(b)
b_index=-1
for a_item in a:
b_index +=a_item
b_index=b_index%len(b)
wp.append(b.pop(b_index))
b_index -=1
print(wp[N-M])
while True:
try:
N,M=map(int,input().split())
L,R=map(int,input().split())
if N>=M and R>=L and L>=1 and M>=1 and (R<=105 or (N-M)<=108):
a=[0]*N
a[0]=L
wp=[]
b=[i for i in range(1,N+1)]
for i in range(1,N):
if a[i-1]==R:
a[i]=L
else:
a[i]=a[i-1]+1
solve(a,b)
else:
break
except:
break