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.
This commit is contained in:
Pat Wick 2023-08-07 10:03:50 -04:00
parent 01865afe8c
commit d8a5934cb5
1 changed files with 24 additions and 2 deletions

View File

@ -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]