Monday, March 22, 2010

UVa, SPOJ & TopCoder




First of all, thanks to Fahim vai, he gave me the idea first...

This is a very easy way to add a cool bookmark item on your browser which can easily locate UVa, SPOJ & TopCoder problems for you. After you follow these steps, you will be able to open any UVa / SPOJ problem with just a click, you even do not need to enter any web address !

UVa Locator:


Right click on bookmark toolbar of your browser. Then right click on it and select "New Bookmark...". So the new bookmark box will arrive. On the name field, put whatever you want, like "UVa" or something else and on the location field, paste the following javascript:

javascript:var%20pid=prompt('Enter%20problem%20number:');
location.href='http://uva.onlinejudge.org/external/'+pid.substring(0,pid.length-2)+'/'+pid+'.html';

Now, after clicking "Add", you will see a new bookmark item has been added to your browser's toolbar, just click on it and enter the problem number.. that's it!




























Spoj Locator:


Similar process, add e new bookmark item, now, give a different name, for example, "SPOJ" and on the location, paste the following javascript:

javascript:var%20pid=prompt('Enter%20problem%20name:');
location.href='https://www.spoj.pl/problems/'+pid.toUpperCase()+'/'

Click "Add" and done!. Now you will get a similar bookmark item as the previous one. But as you know, spoj problems are recognized with their codnames, not numbers. So enter a code name in the textbox, don't bother about case, and click ok. It will open the page of the problem if it is there. For example, to open the problem "Longest Common Substring", it has a codename LCS, you should enter "LCS" in the box, (not necessarily all should be uppercase).


TopCoder Locator:


Similarly, topcoder problems are known by their respective class names, you can add a simple search box for topcoder problems by adding the following javascript in the similar way stated above:

javascript:var%20pid=prompt('Enter%20class%20name:');
location.href='http://www.topcoder.com/tc?module=ProblemArchive&class='+pid
It will not open the problem, it is a simple javascript that calls the search engine on topcoder to find the class name you provide.

As these will open in current window, make sure you open a new tab before using these to save some back, forward clicks ><><><
Have Fun !!!

6 comments:

  1. You can use window.open(url) instead of location.href=url to avoid opening the page in the same tab.
    so for uva
    javascript:var%20pid=prompt('Enter%20problem%20number:');window.open('http://uva.onlinejudge.org/external/'+pid.substring(0,pid.length-2)+'/'+pid+'.html');

    ReplyDelete
  2. This code is not working. The content current tab vanishes leaving only one line "[object Window]" and the problem opens in another tab,

    ReplyDelete
  3. @Shafaet
    try this, hope it will work
    javascript:if(a=prompt("Enter Problem Number:"))
    if(window.open("http://uva.onlinejudge.org/external/"+a.substr(0,a.length-2)+"/"+a+".html"));

    ReplyDelete
  4. please can you send me some test cases for the problem LASTDIG2 in the spoj actualy i am getting wrong answer in that problem .
    thanx in advance

    ReplyDelete
  5. @Anonymous, for test cases, you should visit spoj forums.

    ReplyDelete