Separate the Numbers

  • + 0 comments

    My python sollution :

    def separateNumbers(s):
        for i in range(len(s)//2):
            n = s[:(i+1)]
            l = 0
            while l < len(s):
                t = str(int(n)+1)
                if s.find(t,l) != -1 :
                    if s.find(n,l) + len(n) != s.find(t,l) :
                        break
                    else :
                        l += len(n)
                        n = t
                else:
                    l += len(n)
                    break
            if l == len(s):
                print(f'YES {s[:(i+1)]}')
                return
        else :
            print('NO')