Another X-mas Coding Contest?

Really sorry guys I'm gonna have to pass on organizing this year due to lack of time :( I've been trying to put something together but it seems to be taking significantly longer that last year. It's difficult to find enough algorithmic/computational based problems that have some element of originality and don't require a maths degree to understand :( I think ideally the problems need to match the difficultly of last year so that they fit to a wide enough audience.

Really hope someone else can pick it up though :) Or if all else fails hopefully I will get a free weekend to plan it some more. I really like the path finding idea suggested above but it might be too complex to have as a single problem to solve.
 
Really sorry guys I'm gonna have to pass on organizing this year due to lack of time :( I've been trying to put something together but it seems to be taking significantly longer that last year. It's difficult to find enough algorithmic/computational based problems that have some element of originality and don't require a maths degree to understand :( I think ideally the problems need to match the difficultly of last year so that they fit to a wide enough audience.

Really hope someone else can pick it up though :) Or if all else fails hopefully I will get a free weekend to plan it some more. I really like the path finding idea suggested above but it might be too complex to have as a single problem to solve.

I've got a couple of ideas. Will see if I can get some time to flesh them out and create a proper challenge from them.
Personally I think the path finding algorithm is a little too difficult for beginners.
I agree that we want something at a similar level to last year's comp.
That was easy enough for relatively inexperienced programmers to pick it up, but also gave a bit of stuff for more advanced coders to do with all the performance tweaks that went on!
 
Really sorry guys I'm gonna have to pass on organizing this year due to lack of time :( I've been trying to put something together but it seems to be taking significantly longer that last year. It's difficult to find enough algorithmic/computational based problems that have some element of originality and don't require a maths degree to understand :( I think ideally the problems need to match the difficultly of last year so that they fit to a wide enough audience.

Really hope someone else can pick it up though :) Or if all else fails hopefully I will get a free weekend to plan it some more. I really like the path finding idea suggested above but it might be too complex to have as a single problem to solve.

I've got a couple of ideas. Will see if I can get some time to flesh them out and create a proper challenge from them.
Personally I think the path finding algorithm is a little too difficult for beginners.
I agree that we want something at a similar level to last year's comp.
That was easy enough for relatively inexperienced programmers to pick it up, but also gave a bit of stuff for more advanced coders to do with all the performance tweaks that went on!

Do you really think the pathfinding algorithm is too complicated? I didn't find it particually complicated when I tried it.

I will have a go at fleshing out a challenge and try and explain it as simply as possible tonight, people can then decide if it's too tough.
 
I would have loved to do this, but sadly don't have enough free time over the next couple of weeks and am on holiday after that :(.

However if I was to do it IMO A* sounds good. It's not very complicated to get the basics set up (I've previously used the tutorial posted above and it's extremely good), but can become very complex when your trying to optimise it. Maybe have the option of having a stock map made (maybe a building or town or whatever), and you have to write the code that builds the A* map as well as the path finding code? Or have the option to make/use a 3D path finding map? I'm really just thinking aloud here but there's plenty of stuff which can be done to it.
 
Try and find a solution to x^3 + y^3 = z^3
where x, y, z are positive whole numbers
I'll contribute to the prize money ;)
 
Last edited:
I would have loved to do this, but sadly don't have enough free time over the next couple of weeks and am on holiday after that :(.

However if I was to do it IMO A* sounds good. It's not very complicated to get the basics set up (I've previously used the tutorial posted above and it's extremely good), but can become very complex when your trying to optimise it. Maybe have the option of having a stock map made (maybe a building or town or whatever), and you have to write the code that builds the A* map as well as the path finding code? Or have the option to make/use a 3D path finding map? I'm really just thinking aloud here but there's plenty of stuff which can be done to it.

I've been thinking about this some more. To simply it we can limit the direction of movements to only up, down left and right. Also making all movable square have the same cost of movement simplifies things more

I was thinking that the program would be given a config file with the number of rows and columns, the start and stop positions and the locations of any obstacles. The program would then have to read in said config file and set up and data structures it intends to use during the calculations. It would then have to output that it was ready to start with a timestamp, calculate the path and then print the timestamp when finished. The path would then be output to the screen. The result could then be passed into some sort of verifier to check that it is correct ( that I would write ).

I'll draft up a proper explanation and outline of the challenge now to see what people think.
 
Last edited:
Pathfinding programming challenge
Summary: Implement a simplified A* pathfinding algorithm

The simplifications:
Movement is restricted to up, down, left and right.
Moveable squares all cost the same to move over

The simplified A* pathfinding algorithm

The world is divided into squares, one square is the starting point and another the destination. You will be given the number of rows and the number of columns. Squares should be numbered from left to right starting in the top left corner, e.g.
Code:
1	2	3	4	5	6
7	8	9	10	11	12
13	14	15	16	17	18
There are obstacles on some squares that mean these squares cannot be moved over, the location of the obstacles will be given using the numbering system above.

To find the path from the start to the destination you need to do the following:

1. Add the starting square to a “possible” list. This list contains all the squares that may become part of the path (they might not though which is why it’s called the possible list).

2. In turn, look at the squares immediately to the left, right, up and down. If these squares are moveable (i.e there isn’t an obstacle on them) add them to the possible list. If you add a square to the possible list you also need to record is parent square, i.e the square from which you would move onto this square, in this case it’s the starting square.
3. Remove the starting square from the possible list and add it to the “closed” list, the closed list contains squares you don’t need to consider.

You then need to work out which square to move to next, this is done be calculating the square with the lowest F score, where F = G + H

G is the movement cost to move to this square ( as per simplification 2, all squares cost the same), this is the cost to move to the parent square + the move cost of this square (i.e how many steps along the path is this square)

H is an estimated cost to move from this square to the destination, this is purely a guess as we don’t know the path to get there. A simple guess is the number of horizontal squares to the destination + the number of vertical squares to the destination.

The F score should be calculated for all squares you added to the possible list in 2

To continue the search:

4. Pick the square on the possible list with the lowest F score

5. Move this square from the possible list to the closed list

6. In turn, look at the squares immediately to the left, right, up and down. If these squares are moveable and not on the possible or closed list add them to the possible list. Remember to record its parent square.

7.If the square you a looking at is already on the possible list calculate the G cost to move to this square from the current one, if this G cost is less than the G cost already associated with the square then you have found a better path to that square. You should update the parent of that square to be the current square and recalculate is G and F scores.

8.Once you have checked the squares up, down left and right you should go to 4 and repeat until when you are doing step 6 you end up looking at the destination square. You have then found your path.

9.To create the path, follow the chain of parent squares back from your current square, this should lead you back to the start.

If you get to the point where the possible list is empty and you haven’t found your destination then there is no path!

Here is a graphical implementation of this simplified algorithm I made when I learnt it. The white squares are on the possible list, the purple have been looked at and are on the closed list, the direction of the ring thing indicates the parent square.

http://youtu.be/OuxkXUsljes

So. What do you guys think? I will come up with the specific details of the competition if people like the idea.
 
Oh I forgot to say, Your implementation wouldn't be expected to be graphical, it should only output the path as the numbers of the squares.
 
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.

Hey,
I didn't run it and compile it, I did read it though - It looks good, but you should note you're value of 15001, as the question is:
"
You need to work out which starting value of n produces the longest sequence chain where n is greater than 0 and less than or equal to 1500000 (1.5 million). NB: There are two values that produce the largest chain, go with the smaller of the two."
 
Back
Top Bottom