Tuesday, August 18, 2009

SMS Typing

0 comments

Of late I have been solving a lot of problems. Here s a problem which you guys can solve.

Cell phones have become an essential part of modern life. In addition to making voice calls, cell phones can be used to send text messages, which are known as SMS for short. Unlike computer keyboards, most cell phones have limited number of keys. To accommodate all alphabets, letters are compacted into single key. Therefore, to type certain characters, a key must be repeatedly pressed until that character is shown on the display panel.

In this problem we are interested in finding out the number of times keys on a cell phone must be pressed to type a particular message.

In this problem we will assume that the key pad of our cell phone is arranged as follows.

---------------------

| | abc | def |

---------------------

| ghi | jkl | mno |

---------------------

| pqrs | tuv | wxyz |

---------------------

| |sp | |

---------------------

In the above grid each cell represents one key. Here SP means a space. In order to type the letter ‘a’, we must press that key once, however to type ‘b’ the same key must be repeatedly pressed twice and for ‘c’ three times. In the same manner, one key press for ‘d’, two for ‘e’ and three for ‘f’. This is also applicable for the remaining keys and letters. Note that it takes a single press to type a space.


Input:
The first line of input will be a positive integer T where T denotes the number of test cases. T lines will then follow each containing only spaces and lower case letters. Each line will contain at least 1 and at most 100 characters.


Output:
For every case of input there will be one line of output. It will first contain the case number followed by the number of key presses required to type the message of that case. Look at the sample output for exact formatting.


Sample Input : Sample Output

welcome to ulab : 29

good luck and have fun : 41


Problemsetter: Shamim Hafiz

Special Thanks: Sohel Hafiz

You can download the solution done by me and my friend amruth at here.
The code was compiled and executed on a gcc compiler

Read More......

Monday, August 17, 2009

Bash SpellChecker

0 comments

Reason for this post is that i tend do a lot of typing mistakes while typing at the terminal:-).
Spell checking in bash can be enabled adding the following line below into your bashrc file

shopt -s cdspell

#pradeep@pradeep-laptop:gedit ~/.bashrc

Add the command mentioned above to the end of the file and save.

That’s all :)

If you want to enable this for all the users, then append this to your /etc/bash.bashrc (in Ubuntu) or /etc/bashrc (in Fedora). Of course, you need the root privilege to edit the files in /etc.

Now try these
cd /hoem
cd /hoe

Ain't it cool.

So by the way what is a bashrc file?
Ok in short it is a script which is run by the bash shell when ever a terminal is invoked once you login.
To know more please see /usr/share/doc/bash/INTRO.gz as in "Ubuntu 9.04". Not sure about other versions. It should be the same according to me.


Read More......

Tuesday, August 11, 2009

Microsoft Visio

1 comments

Ok i don usually like writing about microsoft stuff:-). But saw my friend amarnath installing this software, so writing:-)

Microsoft Visio (pronounced VIZ-ee-oh, not VIZH-ee-oh) is a diagramming program for Microsoft Windows that uses vector graphics to create diagrams. It is currently available in two editions: Standard and Professional.

The Standard and Professional editions both share the same interface, but the latter has additional templates for more advanced diagrams and layouts as well as unique functionality that makes it easy for users to connect their diagrams to a number of data sources and display the information graphically.[1][2]

Microsoft acquired Visio Corporation in 2000. Visio 2007 was released on 30 November 2006. Also released alongside version 2002 were Enterprise Network Tools, an add-on product enabling automated network and directory services diagramming, and the Visio Network Center, a Web site where users could locate the latest network documentation content and exact-replica network equipment shapes from 500 leading manufacturers.[3] The former has been discontinued, while the latter's shape-finding features are now integrated into the program itself.[4]

Microsoft has revealed that the next version of Microsoft Visio will feature the ribbon user interface
Source:Wikipedia



Read More......

Saturday, August 8, 2009

Vim plugin you must install

0 comments

Ok why I am writing this post.Two reasons for it:
1) We have a Web Programming Lab this semester
2) I hardly use windows now:-). Using windows has exponentially decreased:-)

Snipmate.vim is probably the best snippets plugin for vim. A snippet is a piece of often-typed text or programming construct that you can insert into your document by using a trigger followed by a tab. It was written by Michael Sanders.

Here is an example usage of snipmate.vim. If you are a C programmer, then one of the most often used forms of a loop is “for (i=0; condition ; i++) {}”. Without snippets you’d have to type this out every time. Even though it takes just another second, these seconds can add to minutes throughout the day and minutes can add to hours over longer periods of time. Why waste your time this way? With snippets you can type just “for tab” and snipmate will insert this whole construct in your source code automatically! If “i” or “n” weren’t the variable you wanted to use, you can now use tab and shift-tab to jump to next/previous item in the loop and rename them!

Michael also created an introduction video for his plugin where he demonstrates how to use it. Check it out:

snipMate.vim Introductory Screencast from Michael Sanders on Vimeo.



How to install snipmate.vim?

To get the latest version:

1. Download snipmate.zip.
2. Extract snipmate.zip to ~/.vim (on Unix/Linux) or ~/etc/vim (wherever vim is installed)
#pradeep@pradeep-laptop: sudo unzip snipmate.zip -d ~/etc/vim (provided snipmate.zip is in your HOME folder else provide the desired path)
3. Run :helptags ~/.vim/doc or ~/etc/vim/doc
4. Restart Vim.

The plugin comes with predefined snippets for more than a dozen languages (C, C++, HTML, Java, JavaScript, Objective C, Perl, PHP, Python, Ruby, Tcl, Shell, HTML, VimScript). Be sure to check out the snippet files in the “snippets” directory under your ~/.vim or ~\vimfiles directory.

If you need to define your own snippets (which you most likely will need), create a new file named “language-foo.snippets” in the “snippets” directory. For example, to define your own snippets for C language, you’d create a file called “c-foo.snippets” and place snippets in it.

To learn about snipmate snippet syntax, type “:help snipmate” and locate the syntax section in the help file.
Have Fun!

Post in your comments if any queries!

Read More......

Wednesday, August 5, 2009

Install Apache webserver,mysql,perl and php

7 comments

For all those who dont have apache server,mysql,perl and php on your Linux OS here's a way you can install.
People who have installed Fedora 8/9[Full installation] all the above gets installed automatically. But if you have installed other distributions like Ubuntu, Open SUSE, Red Hat etc, here is a way you can do.

If you install the above softwares separately its a very tedious job believe me. But you need not do that. The idea was suggested by my class mate Abdul Munim. There is a package by name XAMPP which installs everything including many cool things.So how do you go about it

So wat is XAMPP??
XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl. XAMPP is really very easy to install and to use - just download, extract and start.

So how do you go about it?
At first you need to download the package file.You can find the file: here
Now copy the file to your home directory.Now you are three steps away:-)

Step 1: Installation
Go to a Linux shell and login as the system administrator root:
#su

Extract the downloaded archive file to /opt:
#pradeep@pradeep-laptop:tar xvfz xampp-linux-1.7.1.tar.gz -C /opt

Warning 1: Please use only this command to install XAMPP. DON'T use any Microsoft Windows tools to extract the archive, it won't work.
Warning 2: already installed XAMPP versions get overwritten by this command.

Step 2: Start
To start XAMPP simply call this command:
pradeep@pradeep-laptop:/opt/lampp/lampp start

You should now see something like this on your screen:
Starting XAMPP 1.7.1...
LAMPP: Starting Apache...
LAMPP: Starting MySQL...
LAMPP started.


Step 3: Test
OK, that was easy but how can you check that everything really works? Just type in the following URL at your favourite web browser:

http://localhost

Now you should see the start page of XAMPP containing some links to check the status of the installed software and some small programming examples.

You are done now. If you any queries/problems regarding the installation,please post in the comments and i will try to fix the problem:-)

Read More......

Friday, July 31, 2009

Power of Yahoo Pipes

0 comments

Was wondering from many days what is this Yahoo Pipes all about. Knew it is something special. When i used it i was completely shocked. Its such a powerfull tool!! How can i describe it???

Pipes is a free online service that lets you remix popular feed types and create data mashups using a visual editor. You can use Pipes to run your own web projects, or publish and share your own web services without ever having to write a line of code.

Where does pipe come into play??
Suppose you are only interested in cricket and football news, Generally when you visit a sports website you see news associated with every sport. With yahoo pipes you can customise your results according to your needs with data inputs from various sports websites. The pipe i created is below:

An another pipe which u guys can create is regarding movie theatres. There are many multiplexes/theatres in Bangalore like Inox,PVR,Fun Cinemas etc.. All of them will have their own websites. You can obtain data from all these websites and create a pipe which gives you info about which movie is in which theatre etc!

Well source of input need not to be from websites alone. It could be a data from feeds of a site, google search results ,yahoo search results and also data from online spread sheets etc.
Once u create your pipe you can publish it and add it google reader, google homepage, yahoo page or embedd in your webisite

Yahoo Pipes is so simple and powerful that any can use learn and develop their own application. This one blog post of mine is not enough to describe the Yahoo Pipes. The feel of you guys learnin and designing your own pipes is completely different. So go ahead and give a try.

To get you started with watch this intro video:

Read More......

Thursday, July 30, 2009

Install VLC 1.0.0 in Ubuntu

0 comments

Earlier in ubuntu , on execution of the following command below you could have installed the latest version of vlc media player

#sudo apt-get install vlc

But doing the same now will not install the latest i.e 1.0.0 version.To install the latest vlc player in ubuntu follow the steps below:

=>At first edit the file : /etc/apt/sources.list file. To do it execute the command below
gksudo gedit /etc/apt/sources.list

For Jaunty Users:

deb http://ppa.launchpad.net/c-korn/vlc/ubuntu jaunty main

For intrepid users:

deb http://ppa.launchpad.net/c-korn/vlc/ubuntu intrepid main

Save and exit the file

=>Install GPG key using the following command

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 7613768D

=>Update sourcelist using the following command

sudo apt-get update

=>Install vlc using the following commnd

sudo apt-get install vlc mozilla-plugin-vlc


Read More......