Problem 002 and 020

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
Norseman
Posts: 2
Joined: Fri Mar 13, 2009 1:40 pm

Problem 002 and 020

Post by Norseman »

Edit: This post has been ████████ according to forum rules.

My (apparently incorrect) answer for problem 2 was ███████. I don't see how it could be incorrect, and I've since done several things to confirm it. Firstly, I saved my list of even Fibonacci numbers. [█, █, ██, ███, ███, ████, █████, ██████, ██████, ██████]. I manually confirmed my list here: http://www.research.att.com/~njas/sequences/A000045. Every item is correct, and I'm pretty sure that Python's built in sum() function works fine. Here's the full (python) code I used:

Code: Select all

███████
    ███████
    ████████
        █████
        ███████
████████
█████████
██████████
███████████
███████████
██████████████
	█████████
	██████
		███████████████
		█████████
		██████████
		█████████████████████████
			█████
I don't see any reason why my answer is wrong. I've even google searched "project euler problem 2 ██████" and found other people who posted the same answer on other websites.

Similarly, I think I have the right answer for problem 20, but apparently project euler won't accept it. I simply used:

Code: Select all

███████████████████████████████
I got back ██████████████████████████████████████████████████ ██████████████████████████████████████████████████████████████████. (Space added to avoid messing up formats.) Project Euler doesn't accept this answer either, and I have no idea why it's wrong.

Can anyone tell me if these actually are wrong answers? Or, if they're not, why project Euler won't accept them?
Last edited by Norseman on Fri Mar 13, 2009 2:48 pm, edited 2 times in total.
quilan
Posts: 182
Joined: Fri Aug 03, 2007 11:08 pm

Re: Problems 2 and 20

Post by quilan »

Please edit your post to remove all numbers & code (as per board FAQ). As for the questions you've posted.

#2) You're missing one or more numbers. Check your code logic perhaps, and look high.

#20) You want the sum of the individual digits of 100!, not 100! itself. For example if it was asking for the digit-sum of 5!, the answer would be 1+2+0 = 3.
ex ~100%'er... until the gf came along.
Image
Norseman
Posts: 2
Joined: Fri Mar 13, 2009 1:40 pm

Re: Problems 2 and 20

Post by Norseman »

#20) Ah, ok. Problem solved.

#2) I'm not missing one or more numbers. Even if my code is wrong, you can check the list of Fibonacci numbers and manually add up the even ones until you will exceed 4 million. I have checked the list twice, first to confirm that all of my numbers were on the list, and second to confirm that there were no other even numbers between the numbers I got.

Update: Okay, the correct answer is greater than 4 million. The problem says:
Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
Either the question should be reworded to "Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed five million." or the answer should be changed.
quilan
Posts: 182
Joined: Fri Aug 03, 2007 11:08 pm

Re: Problems 2 and 20

Post by quilan »

Norseman wrote:
Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
Either the question should be reworded to "Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed five million." or the answer should be changed.
Yeah, I know what you mean, but if I recall correctly, there was some discussion about this a while back and the final consensus was to leave the wording as it stands now. I believe the correct meaning of the phrase [finding individual terms that are each <= 4m] was decided to be the most logically inferred, but you'd have to look up the thread for that.
ex ~100%'er... until the gf came along.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problems 2 and 20

Post by hk »

It's as simple as this:
8 and 9 are smaller than 10. However their sum exceeds 10.
I'm no native speaker but if the sum were not to exceed 4 million I get the feeling that there should have been written
"which does not exceed 4 million."
In other words "which" can only refer to the individual terms and not to the sum.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problems 2 and 20

Post by rayfil »

hk is correct on this one. In the english language, DO is used with a plural subject (while DOES would be used with a singular subject). The word sum being singular and the expression even-valued terms being plural, there should be no ambiguity whatsoever as to which subject should be used with the plural verb.

For obvious reasons, this site has to assume that users will be sufficiently familiar with the English language and its grammar. Otherwise, it would be impossible to describe a problem in such a way that EVERYBODY unfamiliar with the language, or its grammar, would interpret the problem with ultimate clarity.
When you assume something, you risk being wrong half the time.
greg1313
Posts: 2
Joined: Wed Jun 23, 2010 12:30 pm

Problem 2

Post by greg1313 »

What is an "even-valued term" ?
User avatar
Lord_Farin
Posts: 239
Joined: Wed Jul 01, 2009 10:43 am
Location: Netherlands

Re: Problem 2

Post by Lord_Farin »

A term in the sequence that is even. Thus, in the first 10 terms, the even terms are 2,8,34.
Image
greg1313
Posts: 2
Joined: Wed Jun 23, 2010 12:30 pm

Re: Problem 2

Post by greg1313 »

Got it, thanks.
jnash67
Posts: 3
Joined: Wed Jun 23, 2010 11:34 pm

Problem two

Post by jnash67 »

Just solved problem two - "Find the sum of all the even-valued [Fibonacci] terms in the sequence which do not exceed four million."

Going through the first few pages of threads, though, they talk of a different answer. I gather that the question previously used to have the series capped at ONE million, not four million.

Might be worth pointing this out somewhere. I was wondering whether the system was erroneously accepting false answers for a bit.
User avatar
rayfil
Administrator
Posts: 1412
Joined: Sun Mar 26, 2006 5:30 am
Location: Quebec, Canada
Contact:

Re: Problem two

Post by rayfil »

There are several problems where the limit has been modified over time. At first, this was to discourage the use of "ready made" answer lists that had been made available by some users (for whatever reason which seemed "appropriate" to them). A note is generally added to the problem description when the limit is modified, to alert members to verify if they have been working with the current limit.
When you assume something, you risk being wrong half the time.
revived_charly
Posts: 1
Joined: Fri Aug 13, 2010 11:31 pm

Re: Problem 002 and 020

Post by revived_charly »

The question for 002 could be rephrased as: find the sum of the even-valued terms whose sum (that is the total sum of the even valued terms) is less than or equal to 4mil. The even-valued term refers to the terms in the sequence that are even numbers e.g 2,8 and 34 are the even-valued terms from the 10 term sequence.
User avatar
GenePeer
Posts: 112
Joined: Sat Apr 03, 2010 1:14 pm
Contact:

Re: Problem 002 and 020

Post by GenePeer »

revived_charly wrote:The question for 002 could be rephrased as: find the sum of the even-valued terms whose sum (that is the total sum of the even valued terms) is less than or equal to 4mil. The even-valued term refers to the terms in the sequence that are even numbers e.g 2,8 and 34 are the even-valued terms from the 10 term sequence.
Not really, the sum can be greater than 4 million but the terms can not.
Image
Post Reply