Getting Started on Topcoder

I`ll outline the procedure for getting started in Algorithm Competitions in Topcoder.

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 ” College Of Engineering Guindy, Anna University”. This is important to increase our college ratings in colleges rank list. Another important thing is referrer handle – put “vijay03″ ( 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 windows here. 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 289-304, then SRM 343 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 PersistentNumber {
public:
int getPersistence(int);
};


int PersistentNumber::getPersistence(int n) {

}

<%: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 getPersistence(int n) method.Here`s the code again, after filling in the logic.


class PersistentNumber {
public:
int getPersistence(int);
};

int PersistentNumber::getPersistence(int a) {

long long int p=1;
long long int q;
int count=0;

q=a;
while(q>10)
{

a=q;
while(a>=10)
{

p=p*(a%10);
a=a/10;
}
q=p*a;


count++;
p=1;
}

if(q==10)
count++;

return count;
}

<%: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 71/71? 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 :)

About these ads

43 thoughts on “Getting Started on Topcoder

  1. Same as those for widows, just replace the installation instructions of java in windows with those in linux. You will also need to install the build-essential package. Try using apt-get for that.

  2. Pingback: On Topcoder! « Vijay Chidambaram

  3. What I wonder is how are the top coders (very high ranks) program. Do they also program in Topcoder arena and use KawigiEdit ? What editors, IDEs they use for the SRM?

    Yeah, I tried to look up on the videos of previous TCO, TCCC but couldn’t find much helpful. I would be really appreciate if you could post a similar entry about that.

    Thankx,

  4. @sanphu:

    Petr releases screencasts of how he does his SRMs. You will find them in the SRM specific forums at Topcoder.

    Other than that, I think just seeing the code of the people like Petr and tomek will give details about what plugins they use.

  5. thx bro…..nice wrk………but 1 problm is comming with my applet that i hve downloaded firstly in that applet my friend login with his account then after that i have made my account on topcoder but on topcoder site i can able to login by my account but on applet it show invalid/username password but wen i enter username and passwd of my friend then it gets easily login.
    i can able to login on website but noty on applet i don’t know what is the reason.
    if you have solution e-mail me megha131313@gmail.com

  6. Hi Vijay,

    First of all a great thnx for this article. The only reason that has stopped me from competing topcoder is this.

    Till now i don’t know how to code for topcoder not that i don’t algo or logic but as how to begin with. This article has done a wonderful job for people like me in getting the first hurdle.

    I really would love if you could write a article describing the vector and how to do it as people like me use C (Embedded Developer) for daily use.

    Thnx & Regards
    Vikas

  7. I have an interview coming up and I want to practice data structures and algorithms. I joined TopCoder and have done two problems (practice rooms) but I am confused on the point system and choosing problems.

    1. Does the score represent how many test cases you passed? Or does it represent how good your solution is? I only got 150/250 on one and then looked at other peoples solutions (the class was named “Recursive____” so I did it recursively, then everyone did it iteratively and I changed it and only got 75 points.. I do not understand this).

    2. Does time matter in the practice rooms?

    3. Is there a good way to choose problems?? There are just so many it’s overwhelming and I can’t find any that seem relevant to what I want to practice.

    4. Am I supposed to do DIV 1 for the easier problems?

    Please email me or post here if you can help, I really want to ace this interview :).

  8. @Vanessa:
    1. The score reflects the time passed since opening the problem. A longer time between opening and submitting the problem means a lower score. In addition, each resubmit incurs an additional 10% penalty. The quality of your solution doesn’t matter for this score.
    2. Yes, it influences the score (as explained in 1).
    3. You can select problems based on difficulty level (from easy to hard: div2-easy, div2-medium/div1-easy, div2-hard/div1-medium, div1-hard) or you can practice problem categories (such as graph theory, dynamic programming etc). Select “Problem archive” (under Competitions->Algorithm->SRM->Statistics on the left sidebar on the website) to select problems based on several criteria.
    4. Div2 is easier than div1.
    Hope this helps.

  9. Pingback: How to get started with Topcoder « Learntofish's Blog

  10. Pingback: My first SRM – single round match TOPCODER | The Utopian Idiot

  11. I am getting completely black window after providing username , passwd, proxy(with authentication). What should I do .
    Please help I am a beginner using college wifi. I am using proxy server.

So what do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s