From d8a5934cb5f6ed3e854fd5e65b630c98109ddcde Mon Sep 17 00:00:00 2001 From: Pat Wick Date: Mon, 7 Aug 2023 10:03:50 -0400 Subject: [PATCH] modified planning.md to set up design I'm not sure if I grabbed this early or not, but there are no specific questions to answer on this file. If there is anything specific to answer for checkpoint 1 or the overall submission, just let me know and I'm happy to resubmit. As far as planning for numberwords, I think it'll be useful to convert the number to a string right off the bat then just find the length and use that to determine how many numbers we have (and whether it's negative) and what index each digit is located in. It seems pretty straightforward, so I'm hoping the follow-through is what I think it is. --- planning.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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] +