Hey it supposed to be easy but where did i go wrong

https://www.codechef.com/problems/CDIT01

result=[]
def sovle():
    a,b=map(int,input().split(" "))
    arr=list(map(int,input().split(" ")))
    for i in range(a,b+1):
        # TODO: write code...
        if i not in arr:
            result.append(i)
            break

try:    
    test=int(input())
    for _ in range(test):
        sovle()
    for item in result:
        print(item)
except:
    pass

I don’t know why this would not pass, but you can try few things, like

remove the try except block completely

remove the " " parameter in split

UPD - Just for the curiousity, I did the above. It gave AC.

res = []
def solve():
    a,b = map(int, input().split())
    arr = list(map(int, input().split()))
    
    for i in range(a,b+1):
        if i not in arr:
            res.append(i)
            break
t = int(input())
for _ in range(t):
    solve()
for i in res:
    print(i)
1 Like