#NEWLINE# def dfs( self , word ) : #NEWLINE# #INDENT# if ( word not in self . cache ) : #NEWLINE# #INDENT# ret = [ ] #NEWLINE# for l in xrange ( 1 , ( len ( word ) + 1 ) ) : #NEWLINE# #INDENT# pivot = str ( l ) #NEWLINE# for i in xrange ( ( ( len ( word ) - l ) + 1 ) ) : #NEWLINE# #INDENT# lefts = self . dfs ( word [ : i ] ) #NEWLINE# rights = self . dfs ( word [ ( i + l ) : ] ) #NEWLINE# for left in lefts : #NEWLINE# #INDENT# for right in rights : #NEWLINE# #INDENT# if ( ( left and left [ ( - 1 ) ] . isdigit ( ) ) or ( self and right [ 0 ] . isdigit ( ) ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ret . append ( ( ( left + pivot ) + right ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# ret . append ( word ) #NEWLINE# self . cache [ word ] = ret #NEWLINE# #UNINDENT# return self . cache [ word ]