x404.co.uk http://www.x404.co.uk/forum/ |
|
Project Euler http://www.x404.co.uk/forum/viewtopic.php?f=4&t=7224 |
Page 1 of 8 |
Author: | Fogmeister [ Wed Mar 24, 2010 12:55 pm ] |
Post subject: | Project Euler |
Thought I'd create an branch from Fin's exam thread. http://projecteuler.net/index.php?section=about Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems. The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context. I've managed problem 1 and 5 so far as they're the only ones I've tried ![]() I don't know if many people will do these from this forum but please post in spoiler colours (i.e. white) if you have the solution or provide hints etc... |
Author: | Fogmeister [ Wed Mar 24, 2010 1:21 pm ] |
Post subject: | Re: Project Euler |
OK, done 2 and 6 now ![]() Need to do some work now though. |
Author: | Fogmeister [ Wed Mar 24, 2010 1:30 pm ] |
Post subject: | Re: Project Euler |
and now 8 ![]() I need to do some of these in Java as the language I use at work isn't up to much number crunching. |
Author: | finlay666 [ Wed Mar 24, 2010 2:00 pm ] |
Post subject: | Re: Project Euler |
I did one, I have a solution to 282 HOWEVER I need to change it from recursive to iterative as doing it recursively causes a stack overflow ![]() I'd suggest doing one easy then one hard ![]() |
Author: | Fogmeister [ Wed Mar 24, 2010 2:52 pm ] |
Post subject: | Re: Project Euler |
Yeah, after a few lines I realised that it would be possible to work out what the final value is fairly easily by viewing it as a whole rather than individual A(m,n) functions. Will have a go tonight. Will be interesting to compare code (although I'll be in Java or ObjC). |
Author: | Fogmeister [ Wed Mar 24, 2010 3:49 pm ] |
Post subject: | Re: Project Euler |
OK, aiming for 282 and then 11 tonight. 11 is a bit less numbery but a bit more interesting ![]() |
Author: | Fogmeister [ Wed Mar 24, 2010 6:39 pm ] | |||||||||
Post subject: | Re: Project Euler | |||||||||
LOL, well it ran for about 5 minutes and then crashed ![]() |
Author: | Fogmeister [ Wed Mar 24, 2010 8:01 pm ] |
Post subject: | Re: Project Euler |
Well, I'm stuck. I can't seem to work out how to get this to work ![]() Hmm... I wonder if there is a way of storing results into an array and so enabling the algorithm to grab the results without having to run the same iterations over and over. |
Author: | Fogmeister [ Wed Mar 24, 2010 8:26 pm ] | |||||||||
Post subject: | Re: Project Euler | |||||||||
OK, this is good! Definitely a step forward! I can get the result from A(5,0) in around half a second now. |
Author: | Fogmeister [ Wed Mar 24, 2010 9:03 pm ] | ||||||||||||||||||
Post subject: | Re: Project Euler | ||||||||||||||||||
OK, I can run up to A(5,0) or A(4,2) and it runs very quickly. A(5,0) runs in 0.005 seconds. However, if I try to increase any side of these then I get a bad access error. ![]() |
Author: | finlay666 [ Wed Mar 24, 2010 9:57 pm ] | |||||||||
Post subject: | Re: Project Euler | |||||||||
OK, I can run up to A(5,0) or A(4,2) and it runs very quickly. A(5,0) runs in 0.005 seconds. However, if I try to increase any side of these then I get a bad access error. ![]() but it's i,i not i, j so 1,1 2,2 3,3 4,4 5,5 6,6 and 0,0 |
Author: | Fogmeister [ Wed Mar 24, 2010 9:58 pm ] | |||||||||||||||||||||||||||
Post subject: | Re: Project Euler | |||||||||||||||||||||||||||
Yeah ![]() I figured if I could reduce the number of iterations done it would stop it crashing out. I can't work out how to do it any other way? It's kind of like the Towers of Hanoi problem in a way. Each time you increase a number it does everything before it again or soemthing. Fin, have you done this one yet? |
Author: | finlay666 [ Thu Mar 25, 2010 12:22 am ] | |||||||||
Post subject: | Re: Project Euler | |||||||||
No, at my gf's atm as my main pc has VS2008 C++ installed and my laptop only has C# (C++ I can increase the call stack to 1gb or so ![]() It's not iteratively that causes the problem, it's the recursion that is the problem and a stack overflow exception as a result, I have thought of a solution that is more iterative but will give it a shot when I get home. (combination of for/while loops to achieve the result which *SHOULD* not give the error) Did 4 today, so 1,2,6,8,9 and 16 so far The latter challenges are the ranked ones too btw so they may be worth a look for a challenge 16 was a bit of a tricky one in C# due to the double refactoring to scientific notation automatically, got it in the end though ![]() |
Author: | Fogmeister [ Thu Mar 25, 2010 9:01 am ] |
Post subject: | Re: Project Euler |
I got number 9 done this morning. |
Author: | Fogmeister [ Thu Mar 25, 2010 10:41 am ] |
Post subject: | Re: Project Euler |
I gave up on 282 for now. Having a go at problem 17 and I've got an answer but it tells me it's wrong ![]() I've double and triple checked my program and I can't find anything wrong. I've even double checked against several random numbers and it's doing it correctly. Not sure what to do now? |
Page 1 of 8 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |