19 lines
758 B
Python
19 lines
758 B
Python
|
|
def under_20():
|
|
words = 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen'
|
|
return len(words.replace(' ', ''))
|
|
|
|
def under_100():
|
|
ten_words = 'twenty thirty forty fifty sixty seventy eighty ninety'
|
|
digit_words = 'one two three four five six seven eight nine'
|
|
return len(ten_words.replace(' ', '')) * 10 + len(digit_words.replace(' ', '')) * 8 + under_20()
|
|
|
|
def handreds():
|
|
words = 'one hundred two hundred three hundred four hundred five hundred six hundred seven hundred eight hundred nine hundred'
|
|
return len(words.replace(' ', '')) * 100 + len('and') * 99 * 9 + under_100() * 10
|
|
|
|
def count():
|
|
return handreds() + len('onethousand')
|
|
|
|
print(count())
|