Monday, November 18, 2013

An interesting Recursion Problem

While I was refreshing some of my java concepts I came across this site with an interesting problem to be solved using recursion. To brush up i quickly wrote three basic programs, viz, sum to given input, product to given input and value of 2^(given number).

Here's the problem statement:

Write a method that accepts an integer parameter n and returns a string of stars (asterisks) 2n long (i.e., 2 to the nth power).
For example:

CallOutputReason
stringRec(0);"*"20 = 1
stringRec(1);"**"21 = 2
stringRec(2);"****"22 = 4
stringRec(3);"********"23 = 8
stringRec(4);"****************"24 = 16

Here is what I came up with:

private static void stringRec(int i) {
    if (i == -1) {
        System.out.print("*");
    }
    else {
        for (int j = i; j >= 0; j--) {
            stringRec(j - 1);
        }
    }
}

Monday, July 22, 2013

How to install xampp server on ubuntu -12.04

XAMPP is an Acronym for X(to be read as Cross for cross platform), Apache HTTP server, MySQL, PHP and Perl. It is a free open source cross platform web server solution stack package.

From XMAPP version 1.8.2 for linux, the installation process had changed. Previously it was extraction of the tar file to any desired location but now it is by running an executable which pops up a gui window for selecting the components you want to install giving it a windows like feel.

Follow below steps to install XAMPP:
  1. Download the latest version from Apache Friends
  2. Once the download is complete open the terminal and login as root using the command
    su
  3. If this is the first time that you are using the su command then you will have to first set it using the command
    sudo passwd root
  4. Goto the directory in which the installer file was downloaded
  5. Change the permissions to the installer using the command
    chmod 755 xampp-linux-version-installer.run
  6. Run the installer using the command
    ./xampp-linux-version-installer.run
    This will install the xampp server in the /opt/lampp directory
  7. Modify permissions of htdocs folder using the command
    sudo chmod 777 -R /opt/lampp/htdocs/
  8. Start server using command
    sudo /opt/lampp/lampp start
  9. To test if the server is installed type localhost in the browser, the xampp welcome page must be displayed.
The various start-stop parameters of lampp are:

ParameterFunctionality
startStart XAMPP (Apache, MySQL and eventually others)
startapacheStart only Apache
startmysqlStart only MySQL
startftpStart only ProFTPD
startwebminStart only Webmin
stopStop XAMPP (Apache, MySQL and eventually others)
stopapacheStop only Apache
stopmysqlStop only MySQL
stopftpStop only ProFTPD
stopwebminStop only Webmin
reloadReload XAMPP (Apache, MySQL and eventually others)
reloadapacheReload only Apache
reloadmysqlReload only MySQL
reloadftpReload only ProFTPD
restartStop and start XAMPP
securityCheck XAMPP's security
enablesslEnable SSL support for Apache
disablesslDisable SSL support for Apache
backupMake backup file of your XAMPP config, log and data files
oci8Enable the oci8 extenssion

To uninstall XAMPP use the command
sudo rm -rf /opt/lampp

Wednesday, February 20, 2013

A Humble Return...

This is a difficult one to write for a couple of reasons. Firstly its been ages since I even thought about writing anything and secondly it has been an disappointing few days in terms of the football club I support, Arsenal. Losing out to Blackburn Rovers in the FA Cup and the losing to the German side Bayern Munich 1-3 at home in the Champions League leaving themselves almost no chance to qualify for the quarter finals exiting the competition at this stage for the third season running.

Arsenal had lost just one Champions League match after moving to the Emirates Stadium in the 06-07 season and have lost 2 matches in this very season and both to German opposition. After losing the semi-final of the 08-09 season against Manchester United, we managed to go unbeaten against the best of Europe facing the likes of Barcelona, Real Madrid, AC Milan, Internazionale and Juventus for 19 games. The run came to an end against Schalke on 24th October 2012 in the group stage of the competition.

Overall it has been a poor season so far with a lot of excellent records coming to an end. The loss to Blackburn Rovers in the FA Cup a first home loss in the competition since 1977, ending a run of 35 unbeaten home games. Losing to Bradford who were about 65 places below them on penalties (3-2) in the Capital One Cup was another embarrassment mainly because it was a strong side put to do the job but they never took their chances and 3 players missed their spot kicks.  

The wait for silverware has been too long and it looks like it'll be another year without anything going in the cabinet. For all the past seasons there has been one thing Arsenal have consistently done and that is to finish in the top 4 in the Premiere League which is also looking doubtful this year because of the inconsistent form throughout the season.

Unlike most fans I do not want Arsene to go as he has genuinely done a wonderful job at the club and am in complete support of his self sustaining model for the club and when the UEFA's Fair Play rules are implemented it is going to leave us in a very strong position. The rules which were agreed in principle in 2009  and some part of the rules have been implemented at the start of last season, the major rule regarding player transfers which would have ensured that we hold onto our best players was shelved.

I sincerely  hope that Arsene will not lose faith in the players he has because they indeed are a skillful and strong group, unfortunately all most all of them have gone through carer threatening injuries and are taking time to regain their confidence back. Also I hope that the team are going to pull themselves up and repay the faith their manager has in them with quality performances. I see a bright future for Arsenal with the current bunch of youngsters, hopefully they will realise their potential and return Arsenal and Arsene to their Glorious days.