Another X-mas Coding Contest?

I've just started my first year of a comp sci degree and am only one semester in, but I too will have a go.

EDIT:

Managed to work out the first one from last year :)

Don't want to annoy but is this right?
Code:
public struct LongestChain
        {
            public int Length;
            public int startvalue;

        }
        static void Main(string[] args)
        {
            int startvalue = 1;
            int length = 1;
            int valuetemp;
            LongestChain LongestChain = new LongestChain();
            LongestChain.Length = 0;
            LongestChain.startvalue = 0;
            
            for(startvalue = 1; startvalue < 15001; startvalue++)
            {
                if(startvalue != 1)
                {
                    valuetemp = startvalue;
                    do
                    {
                        if(valuetemp % 2 == 0)
                        {
                            valuetemp = valuetemp/2;
                            length = length + 1;
                        }
                        else
                        {
                            valuetemp = (valuetemp * 3) + 1;
                            length = length + 1;
                        }
                    }while (valuetemp != 1);

                    if (length > LongestChain.Length)
                    {
                        LongestChain.Length = length;
                        LongestChain.startvalue = startvalue;
                    }
                    Console.WriteLine(startvalue);
                    valuetemp = 0;
                    length = 1;

                    
                }
            }

            Console.WriteLine(LongestChain.Length + " " +  LongestChain.startvalue);
            Console.ReadLine();
            



        }

produces 276 as the length

and the startvalue as 13255

only thing I didn't think about is the fact there are 2 answers however it asks if the length is > not => so surely after it gets the first greatest length it will be the lowest one as my loop is ascending.
 
Last edited:
I'm actually struggling for ideas tbh :(

Unless i just copy the format of last years with some new problems, not sure...

Why not? As long as the problems are different it would still be pretty fun.

Any chance you can remember the answer to number 1 from last year? :) and check above. I'm new to programming so any feedback is greatly appreciated.
 
How about pathfinding? Implementations should based on the A* algorithm. We could have growing map sizes to see how scalable entries are. We would need to determine a standard way of specifing the start and end points as well as the obstacles so that they can be imported in any language.
 
How about pathfinding? Implementations should based on the A* algorithm. We could have growing map sizes to see how scalable entries are. We would need to determine a standard way of specifing the start and end points as well as the obstacles so that they can be imported in any language.

Um. That went straight over my head. :o :p
 
I am also doing last years just to get ready, done the first two stages.

Don't want to annoy but is this right?

only problem i see is your only going upto 150,000 when you need to go to 1,500,000.

if you go from 0 to 1.5M you just need '>' but if you go from 1.5m down to 0 then you do >= because the first chain is the larger number so you need to overwrite it, then you get the smaller number.

hope that helps.
 
Last edited:
I am also doing last years just to get ready, done the first two stages.



only problem i see is your only going upto 150,000 when you need to go to 1,500,000.

if you go from 0 to 1.5M you just need '>' but if you go from 1.5m down to 0 then you do >= because the first chain is the larger number so you need to overwrite it, then you get the smaller number.

hope that helps.


Fail!

Story of my life, read the ****ing question, probably why I missed out on A's in maths.
 
Back
Top Bottom