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..!!

* * * * *

Monday, March 15, 2010

Algothematics.. All the Mathematics you missed



Algothematics is a new event being introduced in Zealicon '10 (annual TechFest of JSS Academy of Technical Education, Noida). The event will be conducted online. All programmers across the world are, hence, invited.

The event comprises of 15 levels. Each level has an ad-hoc mathematical problem which can either be solved manually (using pen and paper) or by conceiving certain algorithm. The submission requires only the answer to the question. Submission of source-code is not required.

Other tools can also be used for solving the problems. Spreadsheet, PARI-GP, MATLAB are among them. Besides all these we always have GOOGLE with us... :)

Besides all this, Zealicon forum will contain an "Algothematics" thread under "online events" where all sorts of problems and their hints will be discussed. No questions extraneous to the event will be entertained.
LeaderBoard will be available at the home page itself, so that you can constantly check your position among others.

Please do not ruin the basic purpose of event by any hacking stuff. Those not conforming to the rules and regulations will be banned without prior information. Decision of Algothematics Team will be the last.

First two teams reaching the final level will be adjudged victorious..

So pull up your socks, hone your programming skills.. Algothematics is about to begin..!!! (17th March, 00:00)

* * * * *

Friday, February 19, 2010

cmath v/s math.h

Here's a problem with pow() function in cmath and math.h:

With gcc set up, math.h just contains the the usual C function pow(double, double) - so all the functions work because with pow(int, int) both ints get promoted to double by compiler and all is OK.
cmath in more than a wrapper for math.h. First it includes math.h and then undefines a whole lot of stuff that math.h defined, and substitutes the c++ versions.
This includes the pow function declaration.
As the c++ overloaded functions (same as any other c++ compiler), you will get the ambiguity problem - when using pow(int, int).

P.S. - The ambiguity occurs with pow(int, int) because integers can be promoted to floats or doubles, which means that pow(int, int) can fit the so overloaded c++ pow function - so the compiler gets confused.

* * * * *

Thursday, February 11, 2010

How to make a good Website..

Answering the question "how" to make a Website is an easy task for many of us but the question which really puzzles us is "what" makes a good Website. We all visit many sites daily while surfing the net but there are a very few of them which leave an impression in our mind. Many sites are technically fine but fail on aesthetic grounds.

What makes a good WEBSITE:

Content:
The most important element of a website is its content. An interesting, informative and dynamic (updated frequently) content makes people visit the site again and again. The flashy colours or animated images look good at first but they never compell us to visit a site again and again. Only good content can do that.
Web is primarily a visual medium and its quite cumbersome to read text screen after screen. Try to keep the content to the point. Never elaborate.

Visuals:
Try not to Bold and Italicise the text too much, it gives an ameturish touch to your website. Sometimes underlined text get users confused with a hyperlink. Try avoiding it too. Make sure that the font size is even throughout. Do not wildly vary the size unless required.
Leave lots of blank spaces. Text on computer screens is hard to read, so don't cram up your text. Start lots of new paragraphs, and leave plenty of spaces between words and objects. Headings or horizontal rules are a good way to do this.
Do not use flashy colours as explained above. Try to select a good and readable combination of colour scheme. White text on black background may look classy but its difficult to read specially when text size is small.

Technicalities:
There are many things that make your web page look a bit different as what you expected:
  • Different browsers may show your web page differently. Try using a javascript available on net that kills this variation.
  • Sometimes web page view gets distorted on lower resolutions. Give a message on your website as "Website is best viewed in 1024X768" or anything like that.
  • The person viewing the web page may have certain settings different from yours.

Some tips:
  • To prevent your sites to look weird on text-only browsers you can add 'ALT' tags to ALL your images. If there is no alternative text that makes sense, use alt="" - this will help text-only browsers more than you will believe.
  • You can add a site search to your site. This will allow users to search your entire site easily and quickly.
  • Make sure that wherever your visitor is in your site, they can get to any other area. Also make sure they know where they are!!
As earlier said making a website is not a difficult task, it is designing and making people visit it again and again that makes it difficult. You need to make your website pretty different from all the other billions, floating on the internet.

* * * * *

Thursday, February 4, 2010

My way of writing a Quine

Here I m presenting a Quine written by me few days before. A Quine is a program that prints its own source code. In my source code user has an option of printing the source code n number of times.

Here is the code written in c:

#include < stdio.h >
int main()
{
int n;
char c;
FILE *f;
f=fopen(__FILE__,"r");
scanf("%d",&n);
while(n--)
{
while((c=getc(f))!=EOF)
putchar(c);
fseek(f,0,0);
}
return 0;
}



Here is the code written in c++:

#include <fstream>
#include<iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
string a;
cin>>n;
while(n--)
{
ifstream fin(__FILE__);
while(!fin.eof())
{
getline(fin,a,'\n');
cout<<a><<"\n";
}
}
return 0;
}

Wednesday, January 27, 2010

Configuring IIS Web Server



The ASP .NET pages can also be hosted through apache but it requires a hell lot of configurations and changes. An alternate version is IIS web server that comes already installed with your windows OS.
Vista OS has an already installed IIS web sever. One just needs to turn the feature on, through control panel. In XP OS you need to install it through XP CD.

Never try to configure IIS on Vista Basic you will land no where in the end. The OS is not provided with the complete package. ISAPI filters cannot be installed correctly on Vista Basic. Certain features of ISAPI filters need to be checked while hosting the website. The safest option is to configure the server on XP.

The steps for configuring it are:
  • Turn the IIS feature on through control panel.
  • Check installation by typing 'http://localhost:80/' in your browser. IIS page will appear.
  • Goto run and type inetmgr. This makes a window pop up. Window is that of IIS Manager.
  • The next step would be to create a virtual directory for an existing physical directory. For this you need to expand the Web Sites item in the IIS tree, right-click the Default WebSite item and choose New -> Virtual Directory from the menu.
  • Then comes the virtual directory creation wizard. The first step in the wizard is to choose an alias. The alias is the name, a user will use, in his URL to access the files in this virtual directory.
  • The next step in the wizard is to provide an existing physical directory to which the virtual directory will point to. So, this physical directory will be exposed as a virtual directory through its alias.
  • The final step in this wizard is to choose your permissions for the virtual directory. Usually, to host an ASP.NET application, read and execute permissions are enough. Of course, in order to fulfill your needs you can choose other permissions too.

* * * * *

Thursday, January 21, 2010

My submissions to SPOJ problem- TEST

My interest lies in programming languages. Actually, I have a bad habit of trying every type of weird thing and this time I came up with the idea of trying a simple problem in every possible programming language I know. I tried to solve the first problem of SPOJ named Test. Here are my codes:

C:

#include < stdio.h >

int main()
{
int n;
scanf("%d",&n);
while (n!= 42) {
printf(""%d", n);
scanf("%d",&n);
}
return 0;
}

C++:

#include < iostream >
using namespace std;

int main()
{
int n;
cin>>n;
while (n!= 42) {
cout<>n;
}
return 0;
}

C#:

using System;
public class Test
{
public static void Main()
{
int n;
while ((n = int.Parse(Console.ReadLine()))!=42)
Console.WriteLine(n);
}
}

Java:

public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String s;
while (!(s=r.readLine()).startsWith("42"))
System.out.println(s);
}
}

Python:

n = input()
  while n != 42:
  print n
  n = input()

PHP:

< ? php while(1) { fscanf(STDIN,"%d",$n); if ($n == 42) break; print "$n\n"; } ? >


BrainF*ck:

>+[>>,----------[>,----------]+++++[<-------->-]<[>>-<]>+[
-<+++++++[<------>-]<[>>-<]>+[
-<<[>>-<]>+[<<->>->]>
]<+++++++[<++++++>-]>>
]<++++++++[<+++++>-]< [<]<[>>[++++++++++.>]++++++++++.[[-]<]]<]
* * * * *