Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Sieving yields results solution in Clear category for Speech Module by maurice.makaay
UNTIL_TWENTY = ["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"
ZERO = "zero"
def checkio(number):
return " ".join(to_text_parts(number))
def to_text_parts(number):
if number >= 100:
yield UNTIL_TWENTY[number//100 - 1]
yield HUNDRED
number %= 100
if number >= 20:
yield OTHER_TENS[number//10 - 2]
number %= 10
if 0 < number < 20:
yield UNTIL_TWENTY[number - 1]
Oct. 28, 2014
Comments: