Problem 017
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
- nicolas.patrois
- Posts: 118
- Joined: Fri Jul 26, 2013 4:54 pm
- Contact:
-
meesterfly
- Posts: 1
- Joined: Sun Jul 20, 2014 6:24 pm
- jesduarte
- Posts: 2
- Joined: Fri Sep 12, 2014 4:38 pm
Re: Problem 017
Unless I misunderstood something, the instructions for problem 17 are incorrect. It says:
My solution, which was accepted, does not include "one thousand". Hence, the instructions should not say "inclusive". I spent some time trying to figure out why my answer was not accepted and then it occurred to me that "one thousand" should probably be excluded since many other problems involved half-open intervals rather than closed intervals. Thanks.If all the numbers from 1 to 1000 (one thousand) inclusive

-
Bubbler
- Posts: 28
- Joined: Sat Feb 23, 2013 6:12 am
Re: Problem 017
No, the question says the right thing. I get the correct answer only after adding 11("one thousand") at the end, so if your solution is accepted without counting it, you are actually getting a wrong answer which is off by 11.
I would agree with this part, considering so many "under XXX" questions seen so far, but P17 is an odd case.jesduarte wrote:...since many other problems involved half-open intervals rather than closed intervals.

-
Dyscalculia
- Posts: 5
- Joined: Wed Aug 06, 2014 3:38 pm
Re: Problem 017
Same, I've solved it and I included number 1000 in the count. So, there's an error in your code.
- jesduarte
- Posts: 2
- Joined: Fri Sep 12, 2014 4:38 pm
Re: Problem 017
Looks like I misspelled "forty" as "fourty" in some places. I can now verify that indeed "one thousand" is included. Though I already had the correct answer, it was a case of being rewarded for "bad" behavior.

-
joshstrange
- Posts: 2
- Joined: Wed Jan 28, 2015 8:09 pm
Re: Problem 017
Ok, I'm going crazy here. I wrote my code in Javascript and I have the following spellings:
I can send my code to someone if they can look at it. I am off by 240 from the correct answer (I looked up the correct answer but haven't entered it yet). I've read every post here and checked the spelling multiple times but I can't seem to figure out what is going on. Every single number + length that people have posted I have had as well. I AM using "and" between the hundreds and the tens place. Any help would be much appreciated, thank you!
Code: Select all
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
10: 'ten',
11: 'eleven',
12: 'twelve',
13: 'thirteen',
14: 'fourteen',
15: 'fifteen',
16: 'sixteen',
17: 'seventeen',
18: 'eighteen',
19: 'nineteen',
20: 'twenty',
30: 'thirty',
40: 'forty',
50: 'fifty',
60: 'sixty',
70: 'seventy',
80: 'eighty',
90: 'ninety',
1000: 'onethousand'
- dawghaus4
- Posts: 56
- Joined: Fri Nov 29, 2013 2:22 am
Re: Problem 017
Is your program's result high or low?
Have you had your program give you totals for small ranges of number (e.g. 198 to 203) for which you have hand counted the result.
Tom
Have you had your program give you totals for small ranges of number (e.g. 198 to 203) for which you have hand counted the result.
Tom
-
joshstrange
- Posts: 2
- Joined: Wed Jan 28, 2015 8:09 pm
Re: Problem 017
Ok, I feel like a moron. I had a friend at work look it over and notice that I was putting 'and' before number < 100 and > 19 so 'andtwentyone'.
-
AndreasDavour
- Posts: 4
- Joined: Fri Jul 17, 2015 9:54 am
Re: Problem 017
Can someone British please clarify how they use "and"?
I know this have been beaten to death, but the problem formulation is not clear. I have no beef with British English, but the problem clearly is not "foreigner proof"
My solution is off by 27, which is a multiple of 3 and I suspect that mean I'm misusing "and".
Let me clarify my question. I print the numbers, and for all numbers above 100, I add 3 for the "and". Is that grammatically wrong?
I know this have been beaten to death, but the problem formulation is not clear. I have no beef with British English, but the problem clearly is not "foreigner proof"
My solution is off by 27, which is a multiple of 3 and I suspect that mean I'm misusing "and".
Let me clarify my question. I print the numbers, and for all numbers above 100, I add 3 for the "and". Is that grammatically wrong?
- jaap
- Posts: 588
- Joined: Tue Mar 25, 2008 3:57 pm
- Contact:
Re: Problem 017
Does 200 have an 'and' ?AndreasDavour wrote:Can someone British please clarify how they use "and"?
I know this have been beaten to death, but the problem formulation is not clear. I have no beef with British English, but the problem clearly is not "foreigner proof"![]()
My solution is off by 27, which is a multiple of 3 and I suspect that mean I'm misusing "and".
Let me clarify my question. I print the numbers, and for all numbers above 100, I add 3 for the "and". Is that grammatically wrong?
-
AndreasDavour
- Posts: 4
- Joined: Fri Jul 17, 2015 9:54 am
Re: Problem 017
Hmm. Looks like I did not take out the exception on the even hundreds, and added in "and" on those as well. Thanks for the heads up on that. Now I guess I have bigger problems as now my results differ by way more that it originally did. 
-
AndreasDavour
- Posts: 4
- Joined: Fri Jul 17, 2015 9:54 am
Re: Problem 017
I feel I need to discuss this more explicitly. Is there a assigned place where code snippets and such can be posted, as this is not the place?
My result differ from the correct I looked up by a measly three.
My result differ from the correct I looked up by a measly three.
- Georg
- Posts: 157
- Joined: Mon Jan 21, 2008 7:00 am
- Location: Mannheim, Germany
- Contact:
-
AndreasDavour
- Posts: 4
- Joined: Fri Jul 17, 2015 9:54 am
Re: Problem 017
The problem with that place it is only available once you have posted the correct solution...
Anyway. I took a less compact approach and got the correct number.
Anyway. I took a less compact approach and got the correct number.
- BlivetWidget
- Posts: 3
- Joined: Sun Mar 05, 2017 3:07 am
Re: Problem 017
I would like to propose a small edit to the problem which I think may clarify it a bit. Currently the description only gives test cases which are ambiguous wrt counting "and". Allow me to demonstrate:
[*]342 (three hundred and forty-two) contains 23 letters if you count the "and" but not the spaces, and 23 letters (again) if you count the spaces but not the "and"
[*]115 (one hundred and fifteen) contains 20 letters if you count the "and" but not the spaces, and 20 letters (again) if you count the spaces but not the "and"
[*]Single-digit numbers have neither spaces nor "and"
So, the instructions are clear wrt not counting spaces, and you can tell the user to RTFM until the cows come home, but I think replacing 115 with, say, 100 will tighten up the instruction and head off some level of confusion for some users. Anyway, thanks for reading.
[*]342 (three hundred and forty-two) contains 23 letters if you count the "and" but not the spaces, and 23 letters (again) if you count the spaces but not the "and"
[*]115 (one hundred and fifteen) contains 20 letters if you count the "and" but not the spaces, and 20 letters (again) if you count the spaces but not the "and"
[*]Single-digit numbers have neither spaces nor "and"
So, the instructions are clear wrt not counting spaces, and you can tell the user to RTFM until the cows come home, but I think replacing 115 with, say, 100 will tighten up the instruction and head off some level of confusion for some users. Anyway, thanks for reading.
- sjhillier
- Administrator
- Posts: 561
- Joined: Sun Aug 17, 2014 4:59 pm
- Location: Birmingham, UK
- Contact:
Re: Problem 017
Thanks, it's a good point, but given that this is now a rather old problem, and also more than 100,000 people have solved it in its current form, I'd be reluctant to make a change at this stage.BlivetWidget wrote: Tue Mar 07, 2017 1:38 am I would like to propose a small edit to the problem which I think may clarify it a bit. Currently the description only gives test cases which are ambiguous wrt counting "and". Allow me to demonstrate:
...
- BlivetWidget
- Posts: 3
- Joined: Sun Mar 05, 2017 3:07 am
Re: Problem 017
Understandable, but I think it's sometimes worth considering the new users who start at the beginning as I'm doing. And it's no change to the problem itself, just the note at the bottom. But it's up to you, I just saw an opportunity for clarity and wanted to point it out.
- hk
- Administrator
- Posts: 12831
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 017
In my opinion "Do not count spaces or hyphens." is clear enough and I fail to see why you nevertheless start counting them again.

War ruins the life and health of untold numbers of innocent children.
- BlivetWidget
- Posts: 3
- Joined: Sun Mar 05, 2017 3:07 am
Re: Problem 017
In my opinion, my post was clear enough in explaining that the instructions were correct but had room for improvement. I stated this explicitly, yet you came away from it confused. This is a perfect analogy for the problem we're discussing
Please read my post again, and I think you'll see I'm only trying to suggest an improvement. If you can't see an improvement in using test cases which will only be passed by the correct code, well, I can't help you there.
Please read my post again, and I think you'll see I'm only trying to suggest an improvement. If you can't see an improvement in using test cases which will only be passed by the correct code, well, I can't help you there.

