FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
"eight", "nine","ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"]
HUNDRED = "hundred"
def checkio(number):
if number < 20:
return FIRST_TEN[number - 1]
if number < 100:
return OTHER_TENS[int(str(number)[0]) - 2] if int(int(str(number)[1])) == 0 else OTHER_TENS[int(str(number)[0]) - 2] + ' ' +FIRST_TEN[int(str(number)[1]) - 1]
if number < 1000:
if int(int(str(number)[1])) == 0 and int(int(str(number)[2]))==0:
return FIRST_TEN[int(str(number)[0]) - 1] + ' '+ HUNDRED
if int(int(str(number)[1])) == 0:
return FIRST_TEN[int(str(number)[0]) - 1] + ' ' + HUNDRED + ' ' + FIRST_TEN[int(str(number)[2]) - 1]
else:
if int(int(str(number)[2])) == 0:
return FIRST_TEN[int(str(number)[0]) - 1]+ ' ' + HUNDRED + ' '+ OTHER_TENS[int(str(number)[1]) - 2]
else :
return FIRST_TEN[int(str(number)[0]) - 1] + ' '+ HUNDRED + ' '+ FIRST_TEN[int(str(number)[1:3]) - 1] \
if int(str(number)[1]) < 2 else FIRST_TEN[int(str(number)[0]) - 1]+ ' ' + HUNDRED + ' '+ OTHER_TENS[int(str(number)[1]) - 2] + ' '+FIRST_TEN[
int(str(number)[2]) - 1]
TO20 = ("", "one ", "two ", "three ", "four ", "five ", "six ", "seven ", "eight ", "nine ", "ten ", "eleven ",
"twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ", "seventeen ", "eighteen ", "nineteen ")
UP20 = ("", "", "twenty ", "thirty ", "forty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety ")
def checkio(n):
phr100, phr010, phr001 = TO20[n // 100], UP20[n // 10 % 10], TO20[n % 10]
if n % 100 < 20: phr001 = TO20[n % 20]
if phr100: phr100 = phr100 + "hundred "
return (phr100 + phr010 + phr001)[:-1]
FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
"eight", "nine"]
SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"]
HUNDRED = "hundred"
def checkio(number):
words = []
res = ""
if number >= 100:
words.append(FIRST_TEN[number//100 - 1])
words.append(HUNDRED)
number -= 100*(number//100)
if number >= 20:
words.append(OTHER_TENS[number//10 - 2])
elif number >= 10:
words.append(SECOND_TEN[number - 10])
if number%10 != 0 and (number>20 or number < 10):
words.append(FIRST_TEN[number%10-1])
for w in range(len(words)):
if w == len(words) -1:
res += words[w]
else:
res += words[w] + " "
return res