Thread: count the letters in each number between 1 and 1000 inclusive

  1. #16
    Registered User
    Join Date
    Apr 2019
    Posts
    662
    does everyone agree that if i check the numbers 1 to 19 inclusive and they are right, and i check the numbers 10 to 90 inclusive and they are rright there is no point in checking 21 for ecample as it cant be wrong as 1 and 20 are correct.

  2. #17
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,537
    I suspect you won't like this answer, but 40 is spelt "forty".

    I get 21124 with the correct spelling.

    Ironically, your original numeric case statement had the right number of characters.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #18
    Registered User
    Join Date
    Feb 2019
    Posts
    554
    I didn't skim the codes, but you have to account for the hundreds and above, when the magnitude is greater than 1 too:

    100 = one hundred
    200 = two hundreds

    1000 = one thousand
    2000 = two thousands

    1000000 = one million
    2000000 = two millions

    And there is the conjunction "and". Example: 2345 = two thousands, three hundreds and forty five.

    This "and" can happen more than once. Example: 123456: one handred and twenty three thousands, four hundreds and fifty six.

    There is another complexity to add to the mix: Take 1123 and 1023 as examples:

    1123 = one thousand, one hundred and twenty three.
    1023 = one thousand and twenty three (no commas!)...
    Last edited by flp1969; 06-09-2019 at 08:59 AM.

  4. #19
    Registered User
    Join Date
    Apr 2019
    Posts
    662
    yep i just checked that what an idiot lol i was just about to type it allows me to type forty here with out correcting it then realised i had misspelt it in the array
    Last edited by cooper1200; 06-09-2019 at 08:59 AM.

  5. #20
    Registered User
    Join Date
    Apr 2019
    Posts
    662
    @ flp if you wrote down the number 312 in words you would say three hundred and twelve. there would be no plural for the hundred.

  6. #21
    Registered User
    Join Date
    Feb 2019
    Posts
    554
    Quote Originally Posted by cooper1200 View Post
    @ flp if you wrote down the number 312 in words you would say three hundred and twelve. there would be no plural for the hundred.
    This is the coloquial way. In the formal way there is more then ONE hundred in 300, there is 3 hundreds, plural...
    Even if one accepts the coloquial way for hundreds, what about thousands, millions, billions and above?
    Last edited by flp1969; 06-09-2019 at 09:05 AM.

  7. #22
    Registered User
    Join Date
    Apr 2019
    Posts
    662
    ok now this has annoyed me.... i just uncommented the switch statements and it worked!! i haven't changed any of the code all i have done is reorder things in count letters so it prints the words in the right order.

  8. #23
    Registered User
    Join Date
    Apr 2019
    Posts
    662
    flp i except your point but the exercise was for singular hundreds.

  9. #24
    Registered User
    Join Date
    Feb 2019
    Posts
    554
    Quote Originally Posted by cooper1200 View Post
    flp i except your point but the exercise was for singular hundreds.
    Ok... coloquial way it is... so thousands, millions and so forth follow the same rule, right?

    What about the "and"s? They NEED to be counted as well...

  10. #25
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,537
    > And there is the conjunction "and". Example: 2345 = two thousands, three hundreds and forty five.
    > This "and" can happen more than once. Example: 123456: one handred and twenty three thousands, four hundreds and fifty six.
    coop has it right, they are singular when spelling out numbers as words.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  11. #26
    Registered User
    Join Date
    Feb 2019
    Posts
    554
    Quote Originally Posted by Salem View Post
    > And there is the conjunction "and". Example: 2345 = two thousands, three hundreds and forty five.
    > This "and" can happen more than once. Example: 123456: one handred and twenty three thousands, four hundreds and fifty six.
    coop has it right, they are singular when spelling out numbers as words.
    Ok... Even when there are no sub units? For exemple: 2000 = two thousand or two thousands? Which one is wrong?

    Notice, I'm not qualifying the numbers as in "two thousand dollars"...

  12. #27
    Registered User
    Join Date
    Apr 2019
    Posts
    662
    if i was counting somthing i might say i counted in thousands or i counted in hundreds or if someone asked me how much something cost for example. If it was a lot of money i was a little embarrassed about it i might say it cost hundreds. project euler though said to count the word and and not the spaces. and gave an example of three hundred and forty two having 23 letters. so i followed that format.

  13. #28
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,537
    > Notice, I'm not qualifying the numbers as in "two thousand dollars"...
    The plural goes to the subject.

    You don't say "two thousands dollar" for example.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  14. #29
    Registered User
    Join Date
    Feb 2019
    Posts
    554
    Quote Originally Posted by Salem View Post
    The plural goes to the subject.
    You don't say "two thousands dollar" for example.
    Yep... I've got this hence I told not applying "qualifiers" or objects to the spelling.
    One can argue that since quantities greater than a unit are already expressing more then 1 thing, it doen't make sense to use plurals on "hundred", "thousand" and so forth... But I think this is the coloquial way only, isn't it? If the rule is to NEVER use plural to these groupings, then sentences as "I have hundreds of dollars in my pocket" (poket is the object, singular!) or "they were killed by the millions" (They, as the "subject" already express plural!) makes no sense...

    "Oh... but in these examples you are expressing a notion of magnitude only!". The same way one's do when using "thousand", "hundred", etc...

    Well... Quirks of any language, I guess...

    What about the other issue? The usage of "and"? You could substitute "and"s by commas, as in: 1023 "one throusand and twenty three" by "one thousand, twenty three" or 1123 "one thousand, one hundred [and or ,] twenty three"...

  15. #30
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,537
    It's commas all the way, except for the final and.
    Eg
    Twenty two million, three hundred and forty thousand, nine hundred and seventy six.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to count number of spaces, certain letters, etc. in strings?
    By blindchicken11 in forum C Programming
    Replies: 2
    Last Post: 11-29-2011, 04:31 PM
  2. Count number of letters...
    By sponi in forum C Programming
    Replies: 24
    Last Post: 09-14-2011, 10:30 PM
  3. Count Number of Letters in a Word
    By quiksand in forum C Programming
    Replies: 10
    Last Post: 05-14-2010, 11:44 PM
  4. Count number of letters and numbers in a file
    By jtullo in forum C Programming
    Replies: 2
    Last Post: 04-21-2008, 01:33 AM
  5. Count the letters of a string.
    By blackjs in forum C++ Programming
    Replies: 1
    Last Post: 10-17-2001, 10:15 PM

Tags for this Thread