OCUK Xmas Programming Challenge

Associate
Joined
5 Dec 2010
Posts
3
Currently at 500ms on a dual core 2.0Ghz :D Gonna optimize some more, should have a solution in later or tomorrow. Are we allowed to send in further submissions if we make any improvements after the first as long as it's before the deadline?
 
Associate
Joined
1 Mar 2010
Posts
1,389
Can someone help me understand the first challenge?

From what I gather I have to loop through 1 - 1,500,000 as a starting n value and find the smallest n that has the longest chain?
 
Associate
Joined
3 Dec 2006
Posts
594
Can someone help me understand the first challenge?

From what I gather I have to loop through 1 - 1,500,000 as a starting n value and find the smallest n that has the longest chain?

Pretty much, yes. You need to find the number with the longest chain, but there are multiple numbers with the "longest chain", so you choose the smallest one.

I've improved on my previous 500ms result... It now stands at ~200ms, entirely single-threaded.
 
Soldato
OP
Joined
7 Apr 2004
Posts
4,212
Entry submitted. I hope is all works as per the requirements tntcoder.

Yep all received and working correctly thanks :) Runs in at 2.198s on my box.

BTW for judging ill take an average over 3 executions with everyones code running on the same hardware.

Are we allowed to send in further submissions if we make any improvements after the first as long as it's before the deadline?

Yep that's fine, ill just go with the most recent submission at the end.

I've improved on my previous 500ms result... It now stands at ~200ms, entirely single-threaded.

Nice, im not sure there's a huge need for multi-threadding tbh as the threads will probably add a fair chunk of overhead themselves, nice addition learning wise though. Shame I didn't use larger and more demanding numbers for the calculations on hindsight (I naively assumed they would take people at least longer than 1s to crunch :p).
 
Last edited:
Associate
Joined
1 Mar 2010
Posts
1,389
I keep getting 910107 as my answer for challenge 1. Is this one of the values of n that has the longest chain or am I way off?
 
Associate
Joined
14 Jan 2009
Posts
679
Location
Manchester
I keep getting 910107 as my answer for challenge 1. Is this one of the values of n that has the longest chain or am I way off?

It may be because you're using a signed integer and the calculation is too big, try using an unsigned int or unsigned long.

I think I had a similar problem :D

Finished mine, just going to do some optimization and maybe convert it to c++, just to see if there's any benefit.
 
Associate
Joined
24 Jun 2007
Posts
1,869
Location
Landan.
Just to be perfectly clear: the code we produce has to carry out the whole computation every time it runs? That is, we're not allowed to store answers from the previous stage? Because some of the times people are getting are insane.
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
Location
Derbyshire
Done \o/. The whole thing takes just over a second though (E2180 @ 3.2Ghz) :/. Stage 1 takes up most of that.

I thought I'd been clever for stage 1 but clearly I have some tweaks left. Mind you, I haven't written the code for all-out performance.
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
Location
Derbyshire
Just to be perfectly clear: the code we produce has to carry out the whole computation every time it runs? That is, we're not allowed to store answers from the previous stage? Because some of the times people are getting are insane.

That's how I've read it. Every step must be calculated live and fed into other functions that require that result each time.
 
Soldato
Joined
13 Jan 2003
Posts
23,666
Change of tact.. Going for the most ludicrous implementation award :D excessive parallelism for the win..

So far the prime numbers are generated on the GPU.. At the same time the CPUs are doing other bits...
 

Pho

Pho

Soldato
Joined
18 Oct 2002
Posts
9,324
Location
Derbyshire
Change of tact.. Going for the most ludicrous implementation award :D excessive parallelism for the win..

So far the prime numbers are generated on the GPU.. At the same time the CPUs are doing other bits...

How are you calculating using the GPU, via CUDA or something else? (also wouldn't that be classed as an external lib? :p)
 
Back
Top Bottom