Thursday, March 02, 2006

Google India Code-Jam

Recently Google announced the top coder competition for Asia-Pacific Countries. I came across this news from www.itnewsonline.com and thought it would be good to see what is going on. Looks like this is a very well organized competition and anyone can take this online from anywhere. The programming languages allowed are C++ and Java. For more details, go to http://www.google.com/indiacodejam. The registration process is simple and the Java Web Start application that runs on the host machine is cool. They have practice sessions so that candidates can get a feel of the rules and get used to the interface of the application. There are 3 questions in the practice sessions, each of 250, 500 and 1000 points respectively. One could compile and run the code from the Java applet. There are some test input values for which the expected output is provided. So one could test one's program with these inputs befor submitting. The number of points awarded are dependent on how much time a programmer takes between opening a problem and submitting its solution code. One could also gain some points (or lose some) by successfully (or unsuccessfully) challenging another participants code. Overall it is a fun place with good problems to solve in a limited time.

Below is a brief description of the problems that are currently being posed to programmers in practice sessions -

1. You are given a Start number and a Finish number. Both are integers and Start < Finish. You have to count the total number of bits that need to be flipped (1 -> 0 or 0 -> 1) when starting from Start, incrementing by 1 at a time, and reaching the Finish. e.g. if Start = 7 and Finish = 10, the return value should be 7.

2. You have a 11X11 chess board where you can place any number (<=50) of Rooks and Bishops, in any free box. Just as in a ChessBoard game, a Rook "covers" all boxes in the row that it belongs to and all the boxes in the column that it belongs to, except its own block. However, if a Bishop, or another Rook, blocks its coverage path, the remaining blocks on the same row, or column, is not covered by that Rook. Similarly, a Bishop covers all boxes that appear in its diagonal directions, except its own block, until a Rook or another Bishop, blocks its coverage. Your task is to find out the number of blocks covered collectively by all Rooks and Bishops, given the initial positions of all Bishops and Rooks, in an vector of character strings of form "x y Rook", or "p q Bishop".