Last active
August 29, 2015 13:57
-
-
Save saml/9509022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DICT = { | |
1: 'one', | |
2: 'two', | |
3: 'three', | |
4: 'four', | |
5: 'five', | |
6: 'six', | |
7: 'seven', | |
8: 'eight', | |
9: 'nine', | |
10: 'ten', | |
11: 'eleven', | |
12: 'twelve', | |
13: 'thirteen', | |
14: 'fourteen', | |
15: 'fifteen', | |
16: 'sixteen', | |
17: 'seventeen', | |
18: 'eighteen', | |
19: 'nineteen', | |
20: 'twenty', | |
30: 'thirty', | |
40: 'fourty', | |
50: 'fifty', | |
60: 'sixty', | |
70: 'seventy', | |
80: 'eighty', | |
90: 'ninety', | |
100: 'hundred', | |
1000: 'thousand', | |
1000000: 'million', | |
1000000000: 'billion' | |
} | |
def split(n): | |
if n < 100: | |
return n/10*10,n%10 | |
if n < 1000: | |
return n/100*100,n%100 | |
if n < 10000: | |
return n/1000*1000,n%1000 | |
if n < 100000: | |
return n/10000*10000,n%10000 | |
if n < 1000000: | |
return n/100000*100000,n%100000 | |
if n < 10000000: | |
return n/1000000*1000000,n%1000000 | |
if n < 100000000: | |
return n/10000000*10000000,n%10000000 | |
if n < 1000000000: | |
return n/100000000*100000000,n%100000000 | |
def eng(n): | |
if n in DICT: | |
return DICT[n] | |
left,right = split(n) | |
print((left,right)) | |
return eng(left)+eng(right) | |
try: | |
print(eng(200)) | |
except: | |
pass | |
#for x in range(1, 999999999, 13): | |
# print(eng(x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment