generated from mwc/problemset_numberwords
I attempted to plan the process of coding a progra
m so that numbers, when entered, would be written out in words. This process was easy at first, then became more challenging as the numbers became larger. That sounds obvious and somewhat reductive, but it is true. The digits are easy to understand. Numbers 1-9 need to be defined and so you create a list and define them. It also made sense to look for those same patterns that occur in numbers. To group numbers with like numbers as the digits were grouped. For example numbers that end in Teen or the Tens. It hepled to think of these in two ways. The first step I took was to write a number in the millions, read it out loud, then start dividing it into pieces based off of what I said. As I did this I thought it might be a fun way to think about top-down planning. If you gave students a receipe or number and had them read it out loud and based on what you say create like-groups or steps, then think about how to implement them or how onecould use similar solutions to tackle similar problems.
This commit is contained in:
parent
213eb8958a
commit
e2ad9342df
27
planning.md
27
planning.md
|
@ -36,20 +36,45 @@ return digit_names[number]
|
|||
|
||||
## Integers under 20
|
||||
If the integer is under 10, then use the procedure described above.
|
||||
Otherwise, ... (this is where you take over!)
|
||||
Otherwise, this could be broken into two steps. One would be to recognize the digits that the program is already familiar with. This will seperate the number in the second position of the two digit number. for example the 3 in 13 is still a 3. However they are called a different term, so they need a new way to be recognized as "teen" numbers.
|
||||
|
||||
This would be a similar but seperate look up list of numbers.
|
||||
teen_names = [
|
||||
"ten", "eleven", "twelve", thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
|
||||
]
|
||||
return teen_names[number]
|
||||
|
||||
## Integers under 100
|
||||
If the integer is under 99 it would need to be broken into another definition since it would use the digit function above. It would also need to know the teen function in order to distinguish those numbers from the 20-99 set. First we need to identify if there are any other lists or patterns that can be created. We cold do another list and define it as "tens."
|
||||
|
||||
tens_names = [
|
||||
"ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"
|
||||
]
|
||||
return tens_names[number]
|
||||
|
||||
There would also need to be code that administered hyphenated numbers that would combine two of these functions. For example twenty-five. We would need twenty and five.
|
||||
|
||||
## Integers under 1000
|
||||
By this step digits 1-9 are covered. the teens are defined, and tens are as well. The same would have to be done for 100s.
|
||||
|
||||
Once the 100s are defined then it is a matter of combinig the existing elements using the correct verbage. the program would also have to account for supplemental words that are needed to complete the correct numbers like "and", commas, decimals and hyphens.
|
||||
|
||||
It may be reasonable to group some of these into patterns. For example the 100s all are going to end in two zeros, similarly to the thousands that will all end in three zeros. This should be true, unless they are accompanied by a comma. They might be able to be groups into a combination of lists and if/then statements.
|
||||
|
||||
|
||||
## Integers under 1000000
|
||||
Again this would be three similar steps.
|
||||
1-99 is defined. As are the tens, which would account for two digit numbers like thirty-two. The 100s and their syntax would be completed in the previous sequence. Now, what is left is to break down another set of numbers by thousands. This should work considering that hundereds of thousands would be converted using the 100s function, and further specifications would use the tens, teens, and digits functions.
|
||||
|
||||
Again these might be groups becausethey fall into a patter and always have three zeros in their numerical form. However, this might be tough when it comes to hundered of thousands. that should be all of the pieces that you would need to create numbers up to 1,000,000.
|
||||
|
||||
digits, teens, tens, hunderds, thousands.
|
||||
|
||||
## 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?
|
||||
|
||||
I would assum that the process of negative numbers would be essentially the same. One would have to code the recognition of the "-" symbol in terms of writing it out, but the overall process should be the same. Starting with negative digits, then teens, then tens, then hunderds, the thousands. I think that the real difference would occur when trying to add math code into these numbers.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue