Problem 285

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
Raichev_2
Posts: 1
Joined: Sat Apr 03, 2010 5:30 am

Problem 285

Post by Raichev_2 »

From the problem page:
"For example, if k = 6, a = 0.9 and b =  0.55, then (k·a+1)^(2) + (k·b+1)^(2) = 40.05."
but:
(k·a+1)^2 + (k·b+1)^2
=(6·0.9+1)^2 + (6·0.55+1)^2
=6.4^2 + 4.3^2 = 59.45

Am I missing something or being unbelievably thick and failing at simple arithmetic?
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 285

Post by harryh »

Good spot ! There is a mistake in the given example; it will be fixed soon.

Edit: Typos fixed. The actual values are a=0.2, b=0.85, calculated sum=42.05, sq.root=6.484...
amlesh44
Posts: 7
Joined: Mon Feb 25, 2008 4:50 am
Location: Waterloo, Ontario, Canada
Contact:

Re: Problem 285

Post by amlesh44 »

Also, is the given expected value for 1 <= k <= 10 correct? I am consistently getting something other than the given value...though that could just be cause I am wrong :lol:.
Image
scio me nescire
torrocus
Posts: 2
Joined: Sat Apr 03, 2010 8:16 am
Location: Poland
Contact:

Re: Problem 285

Post by torrocus »

Raichev_2 wrote:From the problem page:
"For example, if k = 6, a = 0.9 and b =  0.55, then (k·a+1)^(2) + (k·b+1)^(2) = 40.05."
but:
(k·a+1)^2 + (k·b+1)^2
=(6·0.9+1)^2 + (6·0.55+1)^2
=6.4^2 + 4.3^2 = 59.45

Am I missing something or being unbelievably thick and failing at simple arithmetic?
I also noticed the same mistake. I joined the Project Euler yesterday. At first I thought I didn't understand the task. Now it's clear.
User avatar
GenePeer
Posts: 112
Joined: Sat Apr 03, 2010 1:14 pm
Contact:

Re: Problem 285

Post by GenePeer »

I joined project euler a while back, but i've only been doing the first problems. reached Problem 55 but now i decided to do this problem. I'm really confused on how they calculated the expected value. Could someone post a link or atleast explain how the expected value for the example given was calculated? I'm new to the whole Uniform Distribution concept but i'm open to learn new things :D
Image
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Re: Problem 285

Post by zwuupeape »

Tried, gave up, took a break, tried again - I suspect I might have precision problems. I get exactly the same value for k = 10.

Can anyone confirm:

k = 1000 => 1556.17575
k = 10000 => 15688.738433
Listing
Posts: 7
Joined: Thu Jan 22, 2009 12:01 pm

Re: Problem 285

Post by Listing »

zwuupeape wrote:Tried, gave up, took a break, tried again - I suspect I might have precision problems. I get exactly the same value for k = 10.

Can anyone confirm:

k = 1000 => 1556.17575
k = 10000 => 15688.738433
k = 10000 => 15688.738431
zwuupeape
Posts: 189
Joined: Tue Jun 09, 2009 6:11 pm

Re: Problem 285

Post by zwuupeape »

Yeah, thanks - I got it now :).
dbatche3
Posts: 4
Joined: Sat Apr 03, 2010 6:20 pm

Re: Problem 285

Post by dbatche3 »

I am pretty sure I have the right idea for this one, except that my result for k up to 10 is 10.91995. My results for k up to 1000 and k up to 10000 are also similar to the ones posted above, except slightly bigger. I am pretty sure I'm doing something incredibly stupid, my hope is that by posting this it will get my mind to go in gear.
Image
Listing
Posts: 7
Joined: Thu Jan 22, 2009 12:01 pm

Re: Problem 285

Post by Listing »

dbatche3 wrote:I am pretty sure I have the right idea for this one, except that my result for k up to 10 is 10.91995. My results for k up to 1000 and k up to 10000 are also similar to the ones posted above, except slightly bigger. I am pretty sure I'm doing something incredibly stupid, my hope is that by posting this it will get my mind to go in gear.
k=1 is a special case which needs to be handled manually
dbatche3
Posts: 4
Joined: Sat Apr 03, 2010 6:20 pm

Re: Problem 285

Post by dbatche3 »

I think I figured out my problem, I was assuming that conditions in the limiting case would hold in all cases. I was wrong. Now I just need to make sure all my code is correct...
Image
umisef
Posts: 4
Joined: Thu Apr 01, 2010 1:25 pm

Re: Problem 285

Post by umisef »

k=1 is a special case which needs to be handled manually
For future seekers of help --- this means that the numbers quoted in the earlier posts are for k=2...n, NOT 1...n.
Also, the value for 1000 should be 1556.175760...

(I spent quite some time trying to find my fundamental problem, when in fact I "only" had precision problems, because I didn't realise those values didn't include k=1)
mrtollefson
Posts: 10
Joined: Wed Oct 14, 2009 3:21 pm

Re: Problem 285

Post by mrtollefson »

I can't get the sample problem, and I'm not doing anything special for k=1, so I presume for now that that's effect and cause.

Can someone elaborate some more about the specialty of k=1?

Thanks.
...mrt
User avatar
sfabriz
Posts: 175
Joined: Thu Apr 06, 2006 12:18 am
Location: London - UK

Re: Problem 285

Post by sfabriz »

Very hard to elaborate on k=1, and the reason is that it would spoil the problem solution.
Try to understand what you're doing and you'll also understand immediately why k=1 is kind of "special".
Cheers,
sfabriz
Image
mrtollefson
Posts: 10
Joined: Wed Oct 14, 2009 3:21 pm

Re: Problem 285

Post by mrtollefson »

Thanks. While not seeing yet what I'm supposed to be looking for, I can see how that might be so. :)

Asking another way, then, for 65,536 attempts, I got 491 K=1's, for an EV(1) of 0.007492. For 10^6 attempts I got 7293 K=1's for an EV(1) of .0007293. In 65,536 attempts, I got 16942 K=2's for an EV(2) of 0.517029, and for 10^6 attempts I got 259497 K=2's for an EV(2) of 0.518994.

I know this isn't how to do the final problem. 10^5 loops around 10^6 loops can't be the way. But I wonder if my built-in RAND() function is the wrong one. Are those EV() in line?

...mrt
dbatche3
Posts: 4
Joined: Sat Apr 03, 2010 6:20 pm

Re: Problem 285

Post by dbatche3 »

mrtollefson wrote:Thanks. While not seeing yet what I'm supposed to be looking for, I can see how that might be so. :)

Asking another way, then, for 65,536 attempts, I got 491 K=1's, for an EV(1) of 0.007492. For 10^6 attempts I got 7293 K=1's for an EV(1) of .0007293. In 65,536 attempts, I got 16942 K=2's for an EV(2) of 0.517029, and for 10^6 attempts I got 259497 K=2's for an EV(2) of 0.518994.

I know this isn't how to do the final problem. 10^5 loops around 10^6 loops can't be the way. But I wonder if my built-in RAND() function is the wrong one. Are those EV() in line?

...mrt
Those are reasonable approximations of the real expected values.
Image
jpaulson
Posts: 17
Joined: Thu Dec 05, 2013 7:46 am

Re: Problem 285

Post by jpaulson »

I believe the values posted for k=1000 and k=10000 earlier in this thread were wrong. My AC program gets:
k=1,000 => 1556.18298
k=10,000 => 15688.74566
Image
User avatar
yourmaths
Posts: 47
Joined: Mon Aug 25, 2014 11:00 am

Re: Problem 285

Post by yourmaths »

jpaulson wrote: Fri Nov 28, 2014 4:37 am I believe the values posted for k=1000 and k=10000 earlier in this thread were wrong. My AC program gets:
k=1,000 => 1556.18298
k=10,000 => 15688.74566
I have just completed this problem and I can confirm that these are the correct values. I'm not sure what is going on in the rest of this thread.
level = lambda number_solved: number_solved // 25
Image
Post Reply