TopCoder

Getting Started on Topcoder

Posted on January 29, 2009. Filed under: TopCoder |

I`m including outlines of the procedure for getting started in Algorithm Competitions in Topcoder as written by Vijay in his blog.

So what`s Topcoder?

Its a company that conducts contests on a regular basis in the fields of algorithmic programming and software development.

Why does it do it?

Programming contests are a way of identifying people good programming ( and general computer science ) talent. Companies pay good money to easily identify top talent for their company. Plus Topcoder acts as a sort of mediator between companies who want some custom software built quickly and developers who are willing to take on projects. It gets some money out of this.

So why should we be looking at Topcoder?

One factor is the fun. Another factor for the more earthy among us, is the money. You can win money at various levels in a Topcoder SRM. So lets get to it.

How is Topcoder different from SPOJ?

  • The major difference is the competing style. SPOJ is based on the ACM ICPC model, where you solve problems on your local computer and upload your source file to be judged. On the other hand, Topcoder is based on the Applet Model, where you use a tool given by the people who conduct the contest to write your programs, compile them and submit, all in one place.
  • Time factor. In SPOJ you can code and submit problems at any time of the day and the problem contributes towards your rank. In Topcoder, though you can code and submit problems at any time, only during contest times will it affect your rank.
  • Topcoder lets you see other the code of other people after the contest. In this way, you can see how the really good people are coding and improve your coding style and knowledge.
  • Time factor – Unlike in SPOJ, where you can take your own time to solve a problem, in Topcoder, at least in SRMs, you have to solve problems within a time limit of one hour fifteen minutes. Doing this well takes some fast thinking and speed in coding – things not reflected in SPOJ
  • Professionalism – Topcoder is just a level more professional than SPOJ at conducting programming contests, for the simple reason that it is commercial. After each SRM, you can compare how you did with your friends, other people in your country, and whole lot more. You also get an editorial after each SRM, explaining the solution to each problem, so if you can`t get it in one SRM, you can get it in the next.

So on to our first SRM. First register with Topcoder here. Select “Competition Registration” and click Submit. Then fill out the form it gives you. Country and Country to Represent are the same thing. One important thing is School which denotes your college – give ”Army Institute of Technology”. This is important to increase our college ratings in colleges rank list. Another important thing is referrer handle – put “amit5148″ ( My handle in Topcoder )

Now you`ve just registered for Topcoder SRMs in general. You still need to register for each SRM. More on that later.

How to start practising on Topcoder:

  1. Download the Topcoder arena. Click here to download. You will need Java and Java Web Start for it to run.
  2. Assuming you`d be coding in C++, download g++ for windowshere. Install it using given instructions.
  3. Download KawigiEdit here. Install it using information given here.
  4. Now run your Topcoder arena by double clicking on the applet you downloaded in step 1
  5. Login with your Topcoder username and password.
  6. In the menu given in the Applet, select Practice Rooms, select SRMs, select 1-16, then SRM 145 Div 2.
  7. You should get a message saying, moving to Room ( or something similar )
  8. Once inside the room, click the button next to “coding” in the centre of the screen and click 250.
  9. Another topcoder applet window should open, containing the problem set. You will be using this window to code, compile, test and submit your solution.

The top portion of the window contains the problem statement. The bottom portion contains an area where you can type your code. This is what the coding bottom portion of the screen initially looks like for me.( If you have KawigiEdit that is, otherwise its just blank )


#includes…
using namespace std;


class ImageDithering {
public:
int count(string, vector <string>);

};

int ImageDithering::count(string dithered, vector <string> screen) {

}

<%:testing-code%>
//Powered by [KawigiEdit] 2.0!

This is where Topcoder differs from most other online competitions. There is no main() method in the code! That is because Topcoder evaluates your code in a different manner. It creates an object of your class and runs the method mentioned in the problem statement. This is why the method has to be public. It passes different arguments to the method and checks the return value of the method with expected return value. DONT print out the answer in Topcoder, it doesn’t help you any ( except maybe for debugging ).

Now you have to type your logic into the method specified in the problem statement. In this case, the count(string dithered, vector <string> screen) method.Here`s the code again, after filling in the logic.

 

class ImageDithering

{

  public:

  int count(string dithered, vector <string> screen)

  {

    vector<bool>is(26,false);

    for(int i=0;i<dithered.length();++i)

      is[dithered[i]-'A']=true;

    int res=0;

    for(int i=0;i<screen.size();++i)

      for(int j=0;j<screen[0].length();++j)

        if(is[screen[i][j]-'A'])

          res++;

    return res;

  }

};

 <%:testing-code%>

//Powered by [KawigiEdit] 2.0! 

 

The above is not my best code, was written ages ago, so don’t judge me by that ) After doing this, try clicking on Compile button. You should get a message saying your code compiled without any errors. Now you can test your code with the example cases. After testing, click Submit.

Go to the Applet, click on Practice Options->Run System Test. You should see a dialog box running your code against various arguments and checking the results. If your code fails for any case, you can see which case it is in this window. You can fix your submission and resubmit as many times as you want, in the practice room.

Saw a green 250 with 49/49? Congrats, you`ve just solved your first problem on Topcoder in the practice room ) I`ll cover registering and participating in a Single Round Match ( SRM ) in another article. Have fun in Topcoder )

Read Full Post | Make a Comment ( 4 so far )

SRM 423

Posted on November 6, 2008. Filed under: TopCoder |

For those who are not familiar with TopCoder SRMs, please visit http://www.topcoder.com/tc to know more about SRMs.

SRM 423 was scheduled today at 1730 IST.

Prior to SRM 423 was a chat session with Psyho. I was amazed to know that he actually started programming at 22 and is now red at 25.

Coming to SRM, I was assigned Room 41 in Div 2.

I started with 250 pointer. It was straight forward as usual, but I took longer time than my average to code correctly at 233.74. I can blame lack of practice during last few weeks for that.

Then I moved onto 500 pointer. My first code passed all the test cases except one. I tried to solve it on paper but my solution on paper was not different from my code. So I started considering all possible ways to solve and then realized what I was missing. Finally after passing all the test cases,I submitted it for 385.87.

I was feeling good after solving both 250 and 500 within 25 minutes.

1000 pointer was easier than usual so code was worth 900 points. I took about about 23 minutes to code it. after submitting it for 589.45, visited room’s summary. I was at the top. As there were 9 green coders in my room and none had submitted 900 pointer, I was in doubt for it reaching and passing system tests.

Challenge phase started at 1850 IST. I opened a 500 pointer which was submitted in last few minutes of coding phase.Took about 7 minutes to figure out that he was applying a brute force to find the solution. I challenged it and +50 :).

Then I tried few other 500 pointers too but was not able to figure out any bug. Few minutes later someone sucessfully challenged my 900 pointer :(. Rest of the challenge phase was silent.

I was happy when finally both of my remaning codes passed system tests.

Finally I was ranked 3rd in room and 86th in division.

Overall a good SRM after many days resulting +100 to my points :).

Read Full Post | Make a Comment ( 1 so far )

Liked it here?
Why not try sites on the blogroll...