If we write out the digits of "60" as English words we get "sixzero"; the number of letters in "sixzero" is seven. The number of letters in "seven" is five. The number of letters in "five" is four. The number of letters in "four" is four: we have reached a stable equilibrium.

Note: for integers larger than 9, write out the names of each digit in a single word (instead of the proper name of the number in English). For example, write 12 as "onetwo" (instead of twelve), and 999 as "nineninenine" (instead of nine hundred and ninety-nine).

For any integer between 0 and 999, return an array showing the path from that integer to a stable equilibrium:

Difficulty: EASY
Tags: Fundamentals

Starter code:
def numbers_of_letters(n):
	

Solutions:
digits = 'zero one two three four five six seven eight nine'.split()

def f(n):
	return ''.join(map(digits.__getitem__, map(int, str(n))))

def numbers_of_letters(n):
	result = [f(n)]
	print(n, result)
	while result[-1] != 'four':
		result.append(f(len(result[-1])))
	return result


words = 'zero one two three four five six seven eight nine'.split()
wordify = lambda n: ''.join((words[int(d)] for d in str(n)))

def numbers_of_letters(n):
	result = [wordify(n)]
	while result[-1] != 'four':
		result.append(wordify(len(result[-1])))
	return result


s = 'zero one two three four five six seven eight nine'
ls = s.split(' ')

def numbers_of_letters(n):
	t = [stringa(n)]
	while n != len(stringa(n)):
		n = len(stringa(n))
		t.append(stringa(n))
	return t

def stringa(n):
	return ''.join([ls[int(i)] for i in str(n)])


t = {'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine', '0': 'zero'}

def numbers_of_letters(n):
	x = [''.join([t[i] for i in str(n)])]
	while int(n) != len(x[-1]):
		n = len(x[-1])
		x.append(''.join([t[i] for i in str(n)]))
	return x


NUM = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

def numbers_of_letters(n):
	s = ''.join((NUM[i] for i in map(int, str(n))))
	return [s] + (numbers_of_letters(len(s)) if len(s) != n else [])


numbers_of_letters = f = lambda n, N=['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']: (lambda s: [s] + f(len(s)) if len(s) != n else [s])(''.join((N[i] for i in map(int, str(n)))))


def numbers_of_letters(n):
	names = {'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'}
	result = []
	while True:
		result.append(''.join((names[digit] for digit in str(n))))
		if result[-1] == 'four':
			return result
		n = len(result[-1])


numbers = 'zero one two three four five six seven eight nine'.split()

def f(n):
	return ''.join((numbers[int(i)] for i in str(n)))

def numbers_of_letters(n):
	ans = [f(n)]
	while ans[-1] != 'four':
		ans.append(f(len(ans[-1])))
	return ans


DIGITS = ('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine')

def numbers_of_letters(n):
	n_digits = ''.join((DIGITS[i] for i in map(int, str(n))))
	n = len(n_digits)
	next_n_digits = ''.join((DIGITS[i] for i in map(int, str(n))))
	result = [n_digits, next_n_digits] if n_digits != next_n_digits else [n_digits]
	while len(next_n_digits) != n:
		n = len(next_n_digits)
		next_n_digits = ''.join((DIGITS[i] for i in map(int, str(n))))
		result.append(next_n_digits)
	return result


def numbers_of_letters(n):
	change = {'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'}
	(num, sol) = (''.join((change[x] for x in str(n))), [])
	sol.append(num)
	while num != 'four':
		num = ''.join((change[x] for x in str(len(num))))
		sol.append(num)
	return sol