Reply to topic  [ 113 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next
Project Euler 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
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 :D

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...

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 12:55 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
OK, done 2 and 6 now :D

Need to do some work now though.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 1:21 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
and now 8 :D

I need to do some of these in Java as the language I use at work isn't up to much number crunching.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 1:30 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
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 :D

I'd suggest doing one easy then one hard :)

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Mar 24, 2010 2:00 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
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).

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 2:52 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
OK, aiming for 282 and then 11 tonight.

11 is a bit less numbery but a bit more interesting :D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 3:49 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
finlay666 wrote:
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 :D

I'd suggest doing one easy then one hard :)

LOL, well it ran for about 5 minutes and then crashed :D

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 6:39 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Well, I'm stuck.

I can't seem to work out how to get this to work :D

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.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 8:01 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Fogmeister wrote:
Well, I'm stuck.

I can't seem to work out how to get this to work :D

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.

OK, this is good! Definitely a step forward! I can get the result from A(5,0) in around half a second now.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 8:26 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Fogmeister wrote:
Fogmeister wrote:
Well, I'm stuck.

I can't seem to work out how to get this to work :D

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.

OK, this is good! Definitely a step forward! I can get the result from A(5,0) in around half a second now.

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.

:(

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 9:03 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
OK, this is good! Definitely a step forward! I can get the result from A(5,0) in around half a second now.

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.

:([/quote]

but it's i,i not i, j so 1,1 2,2 3,3 4,4 5,5 6,6 and 0,0

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Wed Mar 24, 2010 9:57 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
finlay666 wrote:
Fogmeister wrote:
Fogmeister wrote:
OK, this is good! Definitely a step forward! I can get the result from A(5,0) in around half a second now.

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

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?

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Wed Mar 24, 2010 9:58 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
Fogmeister wrote:
Fin, have you done this one yet?


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 :D

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Thu Mar 25, 2010 12:22 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
I got number 9 done this morning.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Mar 25, 2010 9:01 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
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?

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Mar 25, 2010 10:41 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 113 posts ]  Go to page 1, 2, 3, 4, 5 ... 8  Next

Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.