Showing posts with label gettingStarted. Show all posts
Showing posts with label gettingStarted. Show all posts

Saturday, February 5, 2011

Getting started with USACO



USACO (or United States of America Coding Olympiad) is a programming competition primarily for students in USA. It allows codes to be written in c, c++, java and pascal programming languages. There are currently three divisions of the USACO: Bronze (easiest but requires some programming ability), Silver, and Gold (hardest). Participants advance through the divisions by performing well in their current division, or in a qualifying round.

Training pages, internet competitions, US Open ( please don't confuse it with the grand slam :P ) form the basic three parts of USACO. Of these three - training pages are of our interest. These pages are designed to develop one's skills in programming solutions to difficult and varied algorithmic problems at one's own pace. In addition to around several problems, there are texts on programming techniques such as greedy algorithms, dynamic programming, shortest path and many more. Enthusiasts find the training pages so useful that people from other countries use them to prepare for their own national or international level competitions. Amazing thing is that today the coders from other countries have out numbered the US participants !! :P

For getting started with USACO you can register by clicking here. After the registration you can begin with the chapters and corresponding sections through the USACO gateway. The submissions at USACO must conform by following rules:
  • All solutions must have a header as follows:
/*
ID: YourId
PROG: the name of program which will be provided in the problem statement itself
LANG: preferred language
*/
  • The input needs to be read from a file named PROG.in (PROG refers to name of the program as mentioned in header) and output written onto another file named PROG.out.
  • The output file must have a whitespace at the end else it will not compile.

Here's my solution to a problem named Dual Palindromes:

/*

ID: vaibhav4

PROG: dualpal

LANG: C++

*/


#include<fstream>

#include<iostream>

using namespace std;

int isPal(string a)

{

 int i,j;

 for(i=0,j=a.size()-1;i<j;i++,j--)

     if(a[i]!=a[j]) return 0;

 return 1;

}

string conv(int decimal, int base)

{

 if(decimal == 0) return "0";

 char NUMS[] = "0123456789ABCDEFGHIJ";

 string result = "";

 do

 {

     result.push_back(NUMS[decimal%base]);

     decimal /= base;

 }while(decimal != 0);



 return string(result.rbegin(), result.rend());

}

int main()

{

 ifstream cin("dualpal.in");

 ofstream cout("dualpal.out");

 int s,n,i,count=0,count1=0;

 cin>>n>>s;

 s++;

 while(count!=n)

 {

     count1=0;

     for(i=2;i<=10;i++)

     {

         if(isPal(conv(s,i)))

             count1++;

         if(count1>=2)

         {

             cout<<s<<"\n";

             count++;

             break;

         }

     }

     s++;

 }

 return 0;

}

Hope it's now easy to get started with USACO..
Happy Coding !!

* * * * *

Saturday, August 21, 2010

Getting started with Linux File System

via my friend Prateek Gupta ...

For those of you coming from windows background, the way the linux filesystem is laid out may seem confusing at first glance…. but that is where this article comes in !

The first thing you should know when working with linux, is that everything is treated as either a file or directory. Yep thats right, even hardware is considered a file by linux, and, speaking of hardware… all your hardware devices are located in the /dev directory, but more on that... later.

Another thing that confuses windows users, is the fact that linux dosen’t use drive letters to distinguish between different partitions and devices. that is to say in linux, the “root” of your filesystem is / whereas in windows it would most probably be C:\ . Drives in linux are “mounted” to directories where their data can then be accessed, so for instance, if you needed to use your thumbdrive, you would plug it into your computer, and then mount it using the “mount” command, which specifies the path to the device ( something like /dev/sdb or /dev/sdc ) and the directory to mount it to (usually /mnt or /media), then you can happily access your drive from the /mnt or /media folder.

Sounds strange right? well yes it does if you come from a windows environment, where the entire operating system is consolidated onto a single drive. However, with linux and the ability to mount devices as directories, it gives the end user much greater flexibility in splitting up their operating system over several drives or partitions.

To understand what I mean when I say that this approach in mounting drives grants flexibility, I must first explain the different folders in linux and what they store / this is the root folder, all other folders come under root.. think of it as C:\ in a Windows context.

/bin this folder contains all the user-essential binaries (programs) that are needed to administer and run your linux system… delete this folder and your system is broken.

/boot as the name suggests, this folder contains configuration files and other necessary files that are needed by the bootloader

/dev this folder contains device files (remember, these files represent physical devices, so be careful when working with them)

/etc this folder contains all the configuration files used by the system, you can also start and stop services (daemons ) from here

/home this folder contains the home folders of all the normal (non – root ) users on the system .. think of it as my documents in windows

/lib this folder contains software libraries

/media this is a mount point for removable devices… this is where you would usually mount your thumbdrives … etc

/mnt this is a temporary mount point

/opt this folder contains add on software (extra software)

/sbin this folder contains binaries that can only be run as the root user (”superuser”)

/tmp this folder contains temporary files that are erased upon reboot

/usr this folder and its subfolders contains user installed programs and utilities and libraries

/var this folder contains files that change alot (”Variable files”)

/root this folder contians the root user’s files

/proc this is a psuedo folder, that contains information about the linux kernel and hardware that is updated in realtime.

Now back to how mounting grants flexibility…

You see, how the different folders all contain parts of the operating system? Well we can actually mount a seperate hard drive for each of this folders. for example, your /home folder can be put on another harddrive than your / which means that you can easily recover your personal files if the harddrive on / fails because the harddrive mounted to your /home folder is seperate from the one that is mounted to your /

So there you have it, you now know a lttle bit more about the nuts and bolts of linux based operating systems.

* * * * *

Thursday, July 15, 2010

Some useful links for building Android Apps

Working on Android Application Development I came across some very useful links that every Android App Developer must follow. Here is my "Delicious.com" account, you can look for all the bookmarks I have saved.
In this post I am recommending some of the important Android forums and websites. By this time you must obviously be familiar with the official Android Developer Website where you can find the entire documentation of the project. Do add yourself to the Android Google Group for asking all your queries. For hosting your applications access its Official Marketplace.
Besides these regular sites which everyone accesses, I m here to share some more websites that can help novice get started and go on further with the Android App development.

(Click the titles for opening the pages)..

Here's Lars Vogel with his tutorial for getting started with Android App Development. Besides getting started, it also teaches to build a hello world app, demonstrates how to build menus and work with preferences, a nice content provider example and how to make a file browser. At last it demonstrates how to deploy your app onto a real device.

This is one of my best recommendations. Some very nice demo projects are hosted on the site. Studying Motto Twitter project can help understand the concepts in depth. Certain API's have also been explained in the tutorials. The use of bluetooth and camera may become very clear refering to their API tutorials.

Nice tutorials by Nithin Warreir. The blog contains some code snippets that help during development of big projects. One can learn implementation of various tools of Android development easily here. I have even added the admin to my gmail contacts and regularly ask him to review my applications.

Anddev forum is pretty famous for having a large number of online users everytime. For any query you can easily post a question in this forum. Wait for the help that comes in just a few minutes. One can also use the android tag of Stackoverflow, but mind you, it's lame..!! Too slow responses and you'll end answering your own question later which doesn't contribute to the repo at all.. :P

Besides the Official Marketplace, this is another marketplace that hosts developer's applications. For registering as developer in the official marketplace, one needs to pay $25, here lies the advantage of joining SlideMe, it is free..!!
Register yourself and deploy all your apps. The apps may be free or paid. The paid apps can only be downloaded from Android Phone through SlideMe market app. The website asks for copies of your project's ".apk" file and forms an inventory and on downloads you need to generate an invoice to redeem the money. Here is link for viewing my apps.

Happy developing ;)

* * * * *

Wednesday, June 2, 2010

Getting started on Android Application Development


Working as an intern at webkul, I set up Android on my PC. Here's the entire documentation I submitted.

Simple Steps for getting started with the Android Application Development on Windows:

Step-1: Downloads

Step-2: Configure Ellipse

  • Start Eclipse
  • Goto to Help->Install New Software.
  • Hit Add.
  • For the name, type “Android” and set the link to https://dl-ssl.google.com/android/eclipse/” (if this doesn’t work, try it with http:// instead of https://).
  • Click OK.

Step-3: Add ADT (Android Development Tools)

Step-4: Configure Android SDK

  • Start SDK Setup.exe.
  • Install all the packages needed.
  • SDK Manager installs the tools.

Step-5: Set up Android Virtual Device

  • Click on Virtual Devices in SDK Manager.
  • It creates an Android device that will test run the programs.
  • In the name field: “any name”
  • In target field: “Android 2.2 – API Level 8”
  • Select Size as 20.
  • Hit create.
  • Select AVD from list
  • Hit Start

Step-6: Configure Eclipse again

  • Open Eclipse
  • Goto Window->Preferences
  • Select the Android tab.
  • Browse to the location of your Android SDK
  • Hit Apply.
  • Hit OK.

Step-7: Create a new Project

  • Goto File->New->Projects
  • Select Android Projects.
  • Fill the required fields.
  • Hit Finish
  • Start Coding.

Step-8: Run Your Program

  • Press F11.
  • Hit Save.
* * * * *

Monday, March 29, 2010

Getting started with Programming Contest Control (PC2)



After a grand success of JSSATEN techno-cult fest Zealicon '10, I wanted to redirect myself to blogging. So, here I m with another post in which I would like to share my experience with Programming Contest Control (PC2) software.

PC2 is a dynamic, distributed real-time system designed to manage and control Programming Contests. PC2 operates using a client-server architecture. Logging into a client using one of several different types of PC2 accounts (Administrator, Team, Judge, or Scoreboard) enables that client to perform common contest operations associated with the account type, such as contest configuration and control (Administrator), submitting contestant programs (Team), judging submissions (Judge), and maintaining the current contest standings (Scoreboard).

Here are the steps to begin with PC2 software:
  • Install Java (version 1.3.1 or greater).
  • Donwnload PC2 software from here ( I prefer version 8 ).
  • Edit the pc2v8.ini file to point servers and clients to the server IP:port and put the modified .ini file on every server and client machine.
  • Start a PC2 server by running “pc2server.bat” and answer the prompted question as "no".
  • Start a PC2 Admin client by running “pc2admin.bat” and login using the name “root” and password “root”.
  • Do not forget to change the username and login after that.
  • Configure the Admin.
  • Admin: Generate the number of teams, judges, admins, scoreboards you need.
  • Admin: Add the problems from the problem tab.
  • Admin: Define the languages allowed in your competition from the language tab.
  • Admin: Configure the clock from the Time/Reset tab. You can start and stop the contest from this tab.
  • Start all PC2 Judge clients by running “pc2judge.bat” and login ( for judge1 ) using the name “judge1” and password “judge1” and hence for other judges.
  • Judge: Judge receives all the source codes submitted by the teams and has to judge them right or wrong.
  • Start all PC2 Team client running “pc2team.bat” and login ( for team1 ) using the name “team1” and password “team1” and hence for other teams.
  • Team: The teams can send their source code by browsing it, selecting the problem and selecting the language.
  • Team: Teams get prompted whenever a decision is made about their source code and the scoreboard automatically updates as a team succesfully submits a problem.
So, here is the minimal use of PC2 software. For running a multisite contest or automated compilation of source code please refer the its documentation.
Happy coding..!!

* * * * *

Wednesday, January 6, 2010

Why, what n how to Blog..


Why to Blog?

My Blogging habit commenced from January 2009 and I still love it a lot..!! I have a second blog running parallely. Here is its URL.
Blog is something that displays your thoughts to the outer world. Whatever is in your mind, you can deploy that on your blog, as its all yours. Many use blog for helping others, many use it for storing memoirs, many use them for technical discussions and many for fun and money. If you are addicted to writing.. blogging is your domain for sure.

What to Blog?
Its Important to know where your interest spans. A personal blog may contain all the happenings in your life and pictures to display them. A technical blog may contain certain useful information which you found out recently or which is the latest trend. A news blog may contain all recent updates about world, movies, sports, music etc. The thing that matters is your interest.
The second most important aspect of blogging is the content of your posts. The content must be precise, interesting and informative. For attracting more traffic to your blog you need to get a nice title to your posts. These titles get Googled frequently and increase the page rank of your post.

How to Blog?
There are many sites that offer you space to make your own blog. Some famous ones are Blogger, Wordpress, Tumblr, Procetours. I chose Blogger just because I was not having any idea about the others at that time!! I dont want to shift my blog now because then I will have to compromise with my page rank. Certain pre-built tools and gadgets are provided to the bloggers free from these sites. Javascripts may be used to build own tools.
Now, here are some tips from my side that can help bloggers in monitoring their blog and see who visits them.

Google Analytics: Its Google again :).. The analytics gives you a huge amount of information about the visitors of the blog viz the page they visit, amount of time they spend, the area from where they belong, the site from where they refer, how often they visit, even the operating system they use and the browser too..!! :p Visit Google Analytics, register yourself and your blog and enjoy tracing back your visitors. It will ask to add certain Javascrpit onto your home page and some other operations which can easily be done.

Feedjit: FeedJit is a cool tool. It displays the visitor on your blog in a real time basis. The visitors' location will be displayed on the blog itself at whichever corner you wish to place the tool. On clicking the real time display, it shows every visitor location, the sites from where they referred your blog and the keyword they typed in if they Googled your blog and also to which page did they exit. Go for it.. its free.. at least for now..!! :p

Google Feedburner: Recently added to Google. It allows you to generate feeds and sends them to each of your blog's subscriber. RSS feeds or ATOM, anyone can be chosen to begin with.

If you are interested in money making and have a decent regular traffic, you can add Google Adsense onto your blog. Google provides you with some advertisements of other companies which when clicked by a visitor lets you make money. The advertisements are mostly related to the content of your blog.

All these may help you in forming and maintaining your blog. If you have more information.. comments are surely invited..!!
HAPPY BLOGGING..

* * * * *

Saturday, November 14, 2009

Getting started with Project Euler



Hello folks.. After getting started with SPOJ and TOPCODER, lets get started with another fine programming competition which is Project Euler.

The first question which originates is.. why Project Euler??

My answer.. why not?? If you are interested in programming.. make yourselves interested in mathematical shortcuts and logics for solving problems too. Project Euler is a site that provides you problems that bind you to explore some unexplored areas of mathematics. Now, lets get started..

Steps:
  • Get registered.
  • See the problems from problems tag. There are more than 260 problems at present.
  • Solving problems requires you either to build a source code that computes the asked value or to pick up pen and paper and start solving. My advice.. prefer the earlier one..!! :)
Your profile consists of the number of problems you have solved. Your ranking is based on levels. If you have successfully solved 25 questions you qualify to the level 1 and so on and so forth. On solving a problem its thread gets unlocked and you can check solutions of others in the languages they preferred. Thus, you can compare your code with others.

Your profile gets dissolved if no activity happens in 90 days of time. This happens if you are 0, 1 or 2 level programmer. Level 3 and level 4 programmers are granted immortality, thus, here lies the advantage of being superior.. 8)
So, get started with Project Euler and hone your programming skills..

To see my profile, first register to the site and then type the URL: http://projecteuler.net/index.php?section=profile&profile=vaibhav_pandey

* * * * *

Sunday, October 18, 2009

Getting started with TopCoder..



After successfully coding the first time in Topcoder, I really feel greatful in sharing my experience with all. Simply, it was great. Got to learn a lot of new things. I have started it too late but being in UPTU and that too in a college where seniors are not that into coding, it was still very early.. ;)

So, m writing this post to acquaint my mates with the TopCoder Competitions. What I m goin to discuss is all about the algorithm competitions.
Top Coder is a programming arena where you are given a set of problems and you have to solve them (in your preferred language) in a given amount of time. There are some simple steps to follow before starting with the coding competition:
  • Goto Topcoder site and get yourself registered.
  • Now when you are registered, download the Topcoder arena. You will need Java to be installed in your system for making the applet run.
  • Get yourself an editor(I use KawigiEdit). The editor helps in generating the code required for the competition. If you need help to install it.. read this.
  • Start the contest application and start navigating. There are practice rooms where you can practice the earlier SRM's(single round matches).

SRM are the single round matches which are organized twice every month. You are given three problems to solve. What you need to do is to generate the code using KawigiEdit and simply put your logic in the function provided.
The important point about TopCoder is that you don't use the main() method in your code. All your logic is dumped inside a function and you have to return your answer instead of printing it.
The several phases of the competition are:
  • Coding Phase: During this phase you are given 75mins of time to solve as many problems as you can. What you need to do is to write your code, compile it and after rigourous testing on test cases provided and some of your own test cases, "submit" it.
  • Intermission: 5mins intermission.. I hear a song usually.. :)
  • Challenge Phase: During this phase in 20mins time any of the room members can see your code or you can see theirs. If anyone finds anything wrong with anyone's code, he can simply challenge it. If he succeeds the submitted problem will be discarded and points will fall back to 0.00
  • System Testing Phase: After the challenge phase comes System Testing Phase. This takes a fare bit of time. After near about 20mins you can goto tools and room summary for checking whether your code passed the System Testing or not.
After about 2 hrs of play the result is out..!! If you see your name coloured (Green,Blue,Yellow,Red), feel like a champ. If you are Grey, you need to practice more and more. The colors listed above are in hierarchical order.. i mean Red is the highest pointer(2200+) whereas grey is the lowest(001-899).

Being associated with IEEE, TopCoder is a good platform for being recruited. Moreover, it hons your programming skills, giving your career a boost.

You can watch your entire TopCoder profile by just entering your username in the handle.
I m listing some of the TopCoder handles that will inspire you a lot..
Some foreigners:
ACRUSH
petr

Some Indians:
konqueror
innocentboy
vijay03
shalinmangar (from JSS.. a thing to feel proud of..)

Here's my handle.. its not that good.. I'll improve it further.. m sure..
vaibhavpandey

* * * * *

Saturday, October 3, 2009

Getting started with SPOJ (Sphere Online Judge)

After successfully getting involved in SPOJ I think I must give a little idea of it to others too. SPOJ is an online coding website for practicing ACM-ICPC style problems.
You need to join this website if you are interested in coding and have a thirst to solve new problems otherwise you can sit back and relax hearing your music stuff.. :p

To start with you can register for SPOJ here.
After getting registered you can see number of problems. Right now there are around 4K+ problems at SPOJ. For submitting a problem in whichever language you desire you can click submit and submit your file or directly the source code. One of the best things about online judges is their instant feedback. You dont have to wait for your program to get judged! The judge results are:
  • Accepted – The output from your program perfectly matched the required output. This problem is then added to your list of accepted problems.
  • Time Limit Exceeded – It means your program took too long to execute. Try optimizing your program and check for accidental infinite loops.
  • Wrong Answer – Your program ran on time, but it did not produce the required output.
  • Compile Error -Your program had some syntax error. For these errors, click on the text “Compile Error” in the judge result. It`ll take you a page which will list the compile errors and their line numbers in your program. The compilation error can also be sent to you as mail.
  • Runtime Error – This is usually accompanied by a code like SIGSEV. It can happen due to a lot of reasons, but the two most common are using too much memory ( you can use around 6000*6000*4 bytes of memory ) and not remembering to use int main() and return 0 in your programs. (NZEC error).
Your ranking in SPOJ arena is dynamic. More the number of users who solve the problem you'v solved lesser will be points gained. The points you gain in SPOJ come with the formula:

points= 80/(40+users successfully solved the problem)

So, more the difficult question you solve more points you get and higher is your rank. Even your institute gets ranked on your points. Check your institute's rank here.

Here is my SPOJ handle.. vaibhav_pandey

Start coding now!!!

* * * * *