defgen_with_for(length, letters, result = ''): length = int(length) letters = str(letters) if length == 1: ls = [] for i in letters: ls.append(result+i) return ls else: ls = [] for i in letters: ls += gen_with_for(length-1,letters,result+i) return ls
defgen_with_convert(number, letters): length = len(letters) result = '' while number: number, rest = divmod(number-1, length) result = letters[rest] + result return result
defgen(number, letters): length = len(letters) result = '' while number: number, rest = divmod(number-1, length) result = letters[rest] + result return result