WA in SPOJ MINSEQ

I am getting wrong answer in problem SPOJ.com - Problem MINSEQ
please help me with my this solution ZlcC3u - Online C++ Compiler & Debugging Tool - Ideone.com

Your solution will give wrong answer for most of the cases like (987,9876) and (8769,9876).

1 Like

can anybody tell me where is this going wrong ?`

__author__ = 'Achut'

    try :
        while True:
            a = str(input())
            if a == "":
                break;
            b = str(input())
            t = 0 ;
            flag = 0;
            for i in range(a.__len__()):
                if a[i] > b[0]:
                    t = i
                    flag = 1
                    break;
            if flag is 0 :
                t = a.__len__()
            ans = a[:t]
            ans = ans + b
            ans = ans + a[t:]
            print(ans)
    except:
        pass

`

What should be correct answer for these cases? they are giving 9879876 and 87699876… They must be correct answers aren’t they?? @abhishek1995

Thanks @abhishek1995

@vinayawsm: Correct answers would be 9876987 and 87698769.