OCUK Xmas Programming Challenge

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?
 
I am really looking forward to seeing how you guys are getting it done so quick. I thought my 2.7 seconds was decent!
 
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?
 
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.
 
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:
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?
 
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?
I find two answers with longest chain length. 1126015 for the larger and the correct answer for the smaller.
 
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.
 
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.
 
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.
 
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.
 
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...
 
Mine is finished (in C#) but seems slow compared to some of the other results. Might have to port it to another platform.
 
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