diff --git a/planning.md b/planning.md index 40d428a..d1f5586 100644 --- a/planning.md +++ b/planning.md @@ -38,18 +38,40 @@ return digit_names[number] If the integer is under 10, then use the procedure described above. Otherwise, ... (this is where you take over!) -## Integers under 100 +under_20 = [ + "ten", "eleven", "twelve", "thirteen", "fourteen", + "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" +] +return under_20[number-10] + +## Integers under 100 +tens = [ + "twenty", "thirty", "fourty", "fifty", "sixty", + "seventy", "eighty", "ninety" +] + +return tens[tens_digit] + digit_names[ones_digit] # assuming 1's digit is > 0 ## Integers under 1000 +return digit_names[hundreds_digit] + " hundred " + tens[tens_digit] + digit_names[ones_digit] + ## Integers under 1000000 - +return digit_names[thousands_digit] + " thousand " + digit_names[hundreds_digit] + " hundred " + tens[tens_digit] + digit_names[ones_digit] ## Negative integers down to -1 million We won't deal with negative integers in this problem set, but how would you deal with a negative integer, using the functions above? +Convert number to string, check if first character is '-' +All of the digit indices will depend on the length of the str and whether str[0] is - + +if number[0] == '-': + return "negative " + digit_names[thousands_digit] + " thousand " + digit_names[hundreds_digit] + " hundred " + tens[tens_digit] + digit_names[ones_digit] +else: + return digit_names[thousands_digit] + " thousand " + digit_names[hundreds_digit] + " hundred " + tens[tens_digit] + digit_names[ones_digit] +