Splitting a Numeric String | Function accepts a string and checks if string can be split . ; if there is only 1 number in the string then it is not possible to split it ; storing the substring from 0 to i + 1 to form initial number of the increasing sequence ; convert string to integer and add 1 and again convert back to string s2 ; if s2 is not a substring of number than not possible ; if s2 is the next substring of the numeric string ; Incearse num2 by 1 i . e the next number to be looked for ; check if string is fully traversed then break ; If next string doesnot occurs in a given numeric string then it is not possible ; if the string was fully traversed and conditions were satisfied ; if conditions failed to hold ; Driver code ; Call the split function for splitting the string
def split ( Str ) : NEW_LINE INDENT Len = len ( Str ) NEW_LINE if ( Len == 1 ) : NEW_LINE INDENT print ( " Not ▁ Possible " ) NEW_LINE return NEW_LINE DEDENT s1 , s2 = " " , " " NEW_LINE for i in range ( ( Len // 2 ) + 1 ) : NEW_LINE INDENT flag = 0 NEW_LINE s1 = Str [ 0 : i + 1 ] NEW_LINE num1 = int ( s1 ) NEW_LINE num2 = num1 + 1 NEW_LINE s2 = str ( num2 ) NEW_LINE k = i + 1 NEW_LINE while ( flag == 0 ) : NEW_LINE INDENT l = len ( s2 ) NEW_LINE if ( k + l > Len ) : NEW_LINE INDENT flag = 1 NEW_LINE break NEW_LINE DEDENT if ( ( Str [ k : k + l ] == s2 ) ) : NEW_LINE INDENT flag = 0 NEW_LINE num2 += 1 NEW_LINE k = k + l NEW_LINE if ( k == Len ) : NEW_LINE INDENT break NEW_LINE DEDENT s2 = str ( num2 ) NEW_LINE l = len ( s2 ) NEW_LINE if ( k + 1 > len ) : NEW_LINE INDENT flag = 1 NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT DEDENT if ( flag == 0 ) : NEW_LINE INDENT print ( " Possible " , s1 ) NEW_LINE break NEW_LINE DEDENT elif ( flag == 1 and i > ( Len // 2 ) - 1 ) : NEW_LINE INDENT print ( " Not ▁ Possible " ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT Str = "99100" NEW_LINE split ( Str ) NEW_LINE