Let n be any integer between 1 and 999,999 inclusive. Your challenge is to write a complete program which using stdin or command-line arguments takes in n and outputs the number of times the letter "o" is needed to write all cardinal numbers in standard American English between 1 and n. You can assume that n will always be an integer within the above given range.
You can just use all lowercase letters as I do below. So we count all "o". No need to worry about uppercase "O".
Here is a quick review of how to write English numerals in American English.
one two three four ... nine ten eleven twelve thirteen fourteen ... nineteen twenty twenty-one twenty-two ... twenty-nine thirty ... forty ... fifty ... sixty ... seventy ... eighty ... ninety ... one hundred ... two hundred ... three hundred ... nine hundred ... one thousand ... two thousand ... nine thousand ... ten thousand ... eleven thousand ... ninety-nine thousand ... one hundred thousand ... two hundred thousand ... nine hundred ninety-nine thousand nine hundred ninety nine.
The hyphen for two digit numbers doesn't matter.
The commas don't matter of course. I excluded them above.
Separation between hundreds and tens doesn't matter because we are only counting the letter "o" so 110 can be written as "one hundred ten", or "one hundred and ten". I excluded the "and" above.
For this challenge "hundred" and "thousand" must be preceded by "one" instead of "a" when being used at the beginning of the number. So 1111 must be "one thousand one hundred eleven" instead of "a thousand one hundred eleven".
Here are some more random numerals to clarify.
219873 = two hundred nineteen thousand eight hundred seventy three 615023 = six hundred fifteen thousand twenty three 617610 = six hundred seventeen thousand six hundred ten 423716 = four hundred twenty-three thousand seven hundred sixteen 386031 = three hundred eighty-six thousand thirty one
Here are some samples for what your code should return.
./mycount 1 1
There's only "one" to write so we need only a single "o".
./mycount 10 3
We only need three o's namely in "one", "two", and "four".
./mycount 101 41
Your code must be self-contained and must not connect to the internet, download any files, perform any query, etc. I can already see somebody using google or mathematica with wolfram alpha to do this.
True code-golf. The shortest code in any language wins. Please post your code with some test cases. In the case of ties, I pick the one with the highest upvotes after waiting at least for two weeks. So everyone feel free to upvote any solutions you like.
ands I just dropped my biscuit in my cuppa \$\endgroup\$
os - the only difference I know is the