Created
July 30, 2015 03:06
-
-
Save ksin/d8aeadfb4d12b67782ea 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
# Convert an integer into its English equivalent. | |
def in_words(int) | |
# Your glorious code here | |
end | |
### Test code | |
in_words(4) # => "four" | |
in_words(27) # => "twenty seven" | |
in_words(102) # => "one hundred two" | |
in_words(38_079) # => "thirty eight thousand seventy nine" | |
in_words(82102713) # => "eighty two million one hundred two thousand seven hundred thirteen" | |
# Don't be afraid to go through multiple iterations. Don't try to solve all cases at once. | |
### Things to try at each iteration | |
# 1. Start small. Make it work up to ten. | |
# 2. Now bump it up to 1000. | |
# 3. Is it recursive? | |
# 4. Up to a million. | |
# 5. How much higher can you go? Billions? Trillions? Googol? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment