Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Secret Room by mildm
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"]
def st(number):
n = number // 1000
t = [FIRST_TEN[n-1], "thousand"] if n > 0 else []
n = (number // 100) % 10
t += [FIRST_TEN[n-1], "hundred"] if n > 0 else []
n = (number // 10) % 10
t += [OTHER_TENS[n-2]] if n > 1 else []
n = number % (10 if n > 1 else 20)
t += [(FIRST_TEN+SECOND_TEN)[n-1]] if n > 0 else []
return ' '.join(t)
def secret_room(number):
w=st(number)
return sum(st(i+1)<=w for i in range(number))
Nov. 4, 2023
Comments: