Problem 001

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
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.

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


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
blucosmon
Posts: 2
Joined: Wed Jun 08, 2011 1:45 am

Re: Problem 001

Post by blucosmon »

As I understand the question, the natural numbers unique to 3 and 5 below and not inclusive of 1000 are to be added together. If I run both sets of numbers - for 3 and 5, and eliminate the duplicates, can I expect to get the answer?
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 001

Post by TripleM »

Why don't you try it and see? :)
blucosmon
Posts: 2
Joined: Wed Jun 08, 2011 1:45 am

Re: Problem 001

Post by blucosmon »

TripleM wrote:Why don't you try it and see? :)

I did attempt to solve the problem per my understanding of the problem, but again I was wrong! I think after six of seven tries I'm just not going to get it based on my understanding. Oh well.
User avatar
Molx
Posts: 3
Joined: Tue Jun 07, 2011 6:44 pm
Location: Brazil
Contact:

Re: Problem 001

Post by Molx »

blucosmon wrote:
TripleM wrote:Why don't you try it and see? :)

I did attempt to solve the problem per my understanding of the problem, but again I was wrong! I think after six of seven tries I'm just not going to get it based on my understanding. Oh well.
Don't give up! It is good sometimes to take a break, but come back to the problem later and you will probably see what was wrong and think "How could I not see that?" Happens all the time. And it feels so good when you get that right answer based on your thinking =)
Image
jshowalter
Posts: 2
Joined: Sun Jun 12, 2011 4:17 am

Re: Problem 001

Post by jshowalter »

The problem statement is ambiguous.

Either you want the sum of every number that is divisible by 3 or 5, summing once per divisibility; or you want the sum of every number that is divisible by 3 or 5, but you don't want to add that number to the sum twice.

If you want the sum once, then 15 should be added to the sum once; else it should be added to the sum twice. It is not clear from the instructions which you want.

The problem statement needs to be clear. We're not testing programmers' ability to infer requirements from poorly written requirements, we're testing programmers' ability to follow well-written requirements.
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 001

Post by TripleM »

A knowledge of English is required, and the problem statement is not ambiguous. The alternative you have proposed is simply incorrect grammatically; if that were the question you would be asked to add the multiples of 3 AND the multiples of 5.
jshowalter
Posts: 2
Joined: Sun Jun 12, 2011 4:17 am

Re: Problem 001

Post by jshowalter »

TripleM wrote:A knowledge of English is required, and the problem statement is not ambiguous. The alternative you have proposed is simply incorrect grammatically; if that were the question you would be asked to add the multiples of 3 AND the multiples of 5.
Er, no.

15 is divisible by 3, so it meets the criterion of being a multiple of 3, and should be added to the sum.

15 is also divisible by 5, so it meets the criterion of being a multiple of 5, and should be added to the sum.

Perhaps you meant to specify exclusive-or.

I got the solution you wanted, but did it by writing the code both ways and plugging in first one answer and then the other until it said congratulations.
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 001

Post by TripleM »

No, I didn't mean exclusive or, I meant exactly what I said.

Like I said, you aren't told to add together the multiples of 5 and the multiples of 3, considering them as two separate lists; there is no way to ask that without using the word 'and'. You're asked to add numbers that satisfy a condition; the condition being that they are a multiple of 3 or 5.

There really isn't anything else I can say other than the fact I am 100% confident that question is entirely well defined (and that it won't be changed).

[edit] How about this for a simply analogy..
10 cars drive past you; 2 are red, 2 are green, 2 are blue, and 4 have both red and green on them.
"How many cars had red or green on them?"
"12."
"That can't possibly be right, there were only 10 cars in the first place.."
Spectravideo
Posts: 2
Joined: Sun Jun 12, 2011 5:38 am

Re: Problem 001

Post by Spectravideo »

Oh the power of wording :)
You're asked to add numbers that satisfy a condition; the condition being that they are a multiple of 3 or 5.
JamesPr
Posts: 1
Joined: Sun Jun 26, 2011 7:46 pm

Problem 001

Post by JamesPr »

Hello,

I am trying to code this problem in Python.

I'm not sure why my code isn't working. Right now I am printing every iteration of this code. The adding must be incorrect. Could someone please point me to what is wrong? Thanks!

*Problem 1 Code*
Expand
snipped by hk
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 001

Post by hk »

You're probably new here, but dit you read everything in that red box above this page?

There existed already a topic for this problem and I merged it with that topic.
Reading everything written in this topic will make clear what you are doing wrong.
(it has to do with the number 15 and numbers like that.)
Image
War ruins the life and health of untold numbers of innocent children.
Howdy_McGee
Posts: 1
Joined: Sun Jul 10, 2011 5:56 am

Problem 001

Post by Howdy_McGee »

Whelp apparently i'm stumped pretty early... I don't quite understand, are 5 and 3 supposed to not go over 1000? :S not sure if this is spoilers but meaning 995 would be the limit of 5?
User avatar
jake223
Posts: 61
Joined: Mon Apr 25, 2011 5:15 am
Location: USA
Contact:

Re: Problem 001

Post by jake223 »

yes, that is all correct, but you don't need to know that 995 is the upper limit <= to solve it. think <. keep trying. :)
Image
rjashton
Posts: 2
Joined: Mon Jul 18, 2011 3:47 pm

Re: Problem 001

Post by rjashton »

So I managed to solve this one fairly quickly but I was wondering: if I can't post my code here where can I post it?
Hibernatus34
Posts: 31
Joined: Mon May 16, 2011 7:03 am

Re: Problem 001

Post by Hibernatus34 »

rjashton wrote:So I managed to solve this one fairly quickly but I was wondering: if I can't post my code here where can I post it?
Do you think your code would interest any of us ?
Does it use a revolutionary formula ? (you can't even call it an algorithm for this problem)
If not, why do you want to post your code somewhere ?
Have you read the forum and the PDF ? Haven't you found the exact same solution as yours ?
Image Joined PE in May 2011
Plebian
Posts: 2
Joined: Mon Jul 18, 2011 4:54 pm

Re: Problem 001

Post by Plebian »

Just ran into this website, have only been coding for a couple of days. Trying to pick up Python. Currently have a list that writes itself, and sums the totals. I just need to figure out a way to exclude the multiple numbers from my sum.
(ex: 15, 30, 45)

I've noticed posting code is forbidden, how are we supposed to go about getting help with our code?
Hibernatus34
Posts: 31
Joined: Mon May 16, 2011 7:03 am

Re: Problem 001

Post by Hibernatus34 »

Plebian wrote:I've noticed posting code is forbidden, how are we supposed to go about getting help with our code?
You are challenged to solve the problems on your own.
Once you have solved a problem you gain access to a forum and a PDF, so you can learn better solutions.
Image Joined PE in May 2011
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 001

Post by hk »

Plebian wrote:Just ran into this website, have only been coding for a couple of days. Trying to pick up Python. Currently have a list that writes itself, and sums the totals. I just need to figure out a way to exclude the multiple numbers from my sum.
(ex: 15, 30, 45)

I've noticed posting code is forbidden, how are we supposed to go about getting help with our code?
Do you notice a property that those multiple numbers have in common? (This has nothing to do with coding, but with math)
Image
War ruins the life and health of untold numbers of innocent children.
Plebian
Posts: 2
Joined: Mon Jul 18, 2011 4:54 pm

Re: Problem 001

Post by Plebian »

Well, I notice they're multiple of 3 and 5. I think my problem is with my Counter, I think it's adding the last result past 1000. I'll try to set up a check and it should fix it.

Edit: Yup. That's exactly what it was. Had to reorder my Check so it came earlier in my code.
Edit2: Forum thread's closed but.. wow. The other Python solutions are much more complex and shorter than mine.
243009558he
Posts: 2
Joined: Tue Jul 19, 2011 2:14 pm

Re: Problem 001

Post by 243009558he »

Edit: code snipped by hk.
Post Reply