## Python 147

<!-- language: lang-python -->
    
    def t(n):
     p=o='';r=0 # p is previous string, o is output string, r is recycled bitmap
     while n and r<1023: # 1023 is first 10 bits set, meaning all digits have been recycled
    	s=`n`;i=len(s) # s is the current string representation of n
    	while p.endswith(s[:i])-1:i-=1 # find common ending with prev; s[:0] is "",
           # which all strings end with
    	for j in s[:i]:r|=1<<int(j) # mark off recycled bits
    	o+=s[i:];p=s;n-=1 # concatenate output, prepare for next number
     print o # done

First level indent is space, second level is tab char.