Go to file
Rebecca Hankey c6393e00bf I completed the coding for the numberwords
assignment by defining the code for digits, tens, teens, hundered, thousands, then
numbers under 1,000,000.

This process was challenging, but it felt like the key to this problem solving
was looking for patterns. I really liked the planning stage and saying the numbers outloud as
a planning strategy. Once the groups were established, then the patterns were a copy and adjust process.
I ran the test function frequently.

Starting from the bottom I did the easiest definition first, with the digits, then worked my way up thorugh the
other definitions. The most difficult part was figuring out the exceptions to the "if then"
statements. I knew what the if then statements should return, but the expections were a trial
and error process. For example:
if remainder == 0:
            return f"{int_under_10_to_str(hundreds)} hundred"
        else:
            return f"{int_under_10_to_str(hundreds)} hundred and {int_under_100_to_str(remainder)}"

I understood that if the remainder was nothing then the word that it should produce was hunderd. Since
we were calling for the end of the whole number in the hundreds. However, of course, there
are numbers in the hundreds that do not end in that word, since the other digits create other numbers
like two hundred and fifty two. Fifty two needs to be read and converted into words. It made sense to divide
that hundred and find the remainder, but I was not sure how to have it then read the remainder as a number.

To troubleshoot this I wrote a lot of it on paper. I find myself resorting back to paper to plan.
I ran through the code and drew lines over the pieces in the same way I drew lines over the numbers when
I read them aloud in the planning phase.

Finally, I found myself getting the same error messages over and over. No matter what I
tweaked or adjusted, it was still saying that a couple of the numbers it tried to generate were incorrect.

So, I needed to change my approach. Instead of runnung the test function, I started running examples
to troubleshoot.

(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 123421
one hundred and twenty-three thousand and four hundred and twenty-one
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 598567
five hundred and ninety-eight thousand and five hundred and sixty-seven
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 87652 | say
(problemset-numberwords-py3.12) rebeccahankey@Rebeccas-Air problemset_numberwords % python nw.py 1001
one thousand and one

These worked! I even ran the numbers that the code referenced as being errors and they generated correctly!
It was a great feeling. I also have a Mac so I played with the say function a little which was
oddly gratifying.
2024-11-20 19:07:44 -05:00
.commit_template Initial commit 2024-08-29 12:32:43 +00:00
.gitignore Initial commit 2024-08-29 12:32:43 +00:00
numberwords.py I completed the coding for the numberwords 2024-11-20 19:07:44 -05:00
nw.py Initial commit 2024-08-29 12:32:43 +00:00
planning.md I attempted to plan the process of coding a progra 2024-11-20 17:36:02 -05:00
poetry.lock Initial commit 2024-08-29 12:32:43 +00:00
pyproject.toml Initial commit 2024-08-29 12:32:43 +00:00
test_numberwords.py Initial commit 2024-08-29 12:32:43 +00:00