C some Speed !!

Most programmers know that c programs are the next best thing to assembly language programs in terms of Speed , and here is yet another example .

When solving one of the problems at projecteuler.net.I Suddenly came upon the idea to compare the speed of execution of the same algorithm in different languages.

So here is the program in Three Programming languages , C , Java and Python

First in C

long long  LargestPrimeFactor(long long number) {
		long long n = number , i , Largestfactor = 1;
		for (i = 2; i <= (n / i); i++) {
			while (n % i == 0) {
				Largestfactor = i > Largestfactor? i : Largestfactor;
				n /= i;
		Largestfactor = n > Largestfactor ? n : Largestfactor;

		return Largestfactor;
int main (){
	printf(" %d \n",LargestPrimeFactor(600851475143));

Then in Java

class ex3{
	public static long LargestPrimeFactor(long number) {
		long n = number, factor = 1 , i;
		for (i = 2; i <= n / i; i++) {
			while (n % i == 0) {
				factor = i>factor?i:factor;
				n /= i;
		factor = n>factor?n:factor;
		return factor;
	public static void main(String [] args){

and now in Python

def LargestPrimeFactor(num):
        factor = 1
        while( i<= (n/i) ):
                while( n%i == 0 ):
                        if i>factor :
                                factor = i
                        n /= i
                i += 1
        if n > factor:
                factor = n
        return factor

print LargestPrimeFactor(600851475143)

I computed the times using the time utility in linux .

I expected the c program to win there was no doubt about that , and java was expected to come in second with python last .

$ time ./a.out

real	0m0.003s
user	0m0.004s
sys	0m0.000s

$ time java ex3

real	0m0.114s
user	0m0.084s
sys	0m0.028s
$ time python ex3.py

real	0m0.035s
user	0m0.028s
sys	0m0.004s

From the results its quite visible that c had won over python and python had won over java ,even though java was supposed to be faster than python.

The reason for python winning is that the cost of starting up the JVM is quite high, when compared with the cost of starting the python interpreter.

So lesson learnt If your program is short run it in python when given a choice , but still C is the king of Speed

Ps: This Question on stackoveflow goes over some more details .

Rajapattai Movie Review : ராஜசோத்தை (rajasothai)


What would prompt a perfectly stable minded person like me to suddenly spend 3 hrs of time and 120 rupees at a local theater ? Well the answer could lie in the story, screenplay , acting , or effects in a movie . But sadly that was not the reason this time . The reason this time was that I was not really in a proper state of mind and had been pretty shaken up from being sick for the past week.

So lets analyse the bad choice I made.

Rajapattai is essentially a commercial pot boiler as you can easily guess from the trailer . I have nothing against that , but still I expect a bit of brain effort from the director and the writer .

The real story :

Your usual corrupt politician is after somebody else’s stuff , Hero comes and saves the day,

The END.

The actual story :

அனல் முருகன் (Anal Murugan ) works as a small time actor in movies and aims to become a Big Villain actor. He encounters Dhakshina moorthi in a temple and saves him from a bunch of goons and learns that the goons were sent by Dhakshina moorthi’s son who is after his father wealth . So being the kind-hearted person he is, Vikram (If you still haven’t guessed who Anal Murugan is.) takes him into his custody and protects him.

Dhakshina moorthi’s son wants to get into politics so He needs to give the land on which his father has built and orphanage to MAMA Party Leader AKKA (Who incidentally is revealed later in the film to have been a pimp in the beginning only to climb up the ladder and become a politician).

Then a whole bunch of stuff happens and some how the real villains in the movie get the land , and as expected AKKA betrays Dhakshina moorthi’s son who now joins vikram and tries to get his father’s land back.

To get the land back they must take out the Big Boss Wapa, and as usual vikram does the job and proves AKKA’s crimes and AKKA is killed . The children get their orphanage back.

In the mean time there is a Romance that brews between Vikram and Deeksha Seth, Nothing special here.

That about wraps it up.

The Acting :

Vikram has really put in the effort to look like the character he plays . This is a really amazing transformation after Deiva Thirumagal , and as usual he impresses with his acting skills even though his character suffers from a bad case of cliché syndrome.

The vetran telugu actor K.Vishwanath really impresses in the scenes where he give romance tips to vikram , but other than that he doesn’t have a lot of scope.

Deeksha Seth is passable as the female lead looks gorgeous and she tries to show bit emotion in the extremely limited scope that she has, as eye candy. Its commendable that she has not fallen into the glamour trap nor has she stood with a blank face all the time like many heroines who I do not want to mention.

Pradeep Rawat as wapa is not really that frightening a villain as he was in Ghajini .

The actress who plays AKKA needs to do some research on Sornakka (ச்வர்ணக்கா ) characters like for example the female villain from DHOOL (Another Vikram film)  , She goes around with the same expression on her face for the entire length of her screen time .

All the other actors do their parts justice .

Other Technicalities:

This a big let down by director Suseenthiran who directed movies like Vennila Kabadi Kuzhu and Naan Mahaan Alla ,  that is all there is to say in the direction department.

Music by Yuvan Shankar Raja is boring , nothing really catchy , I was counting the minutes to the end of each song in the theater .

Camera work by R. Madhi is ok , A few stunts are shot well .

Few other points :

The songs in the film were a big hindrance to the and the song in which vikram reportedly appears in 17 different costumes was a big letdown.

I couldn’t bear sitting through the final “Laddu Laddu Rendu Laddu” which features Reema Sen ( Who seems really out-of-place ) and Shriya Saran ( Who hasn’t changed her dance moves for a long time ) .

Overall :

If you must see this movie , either remove your sense of logic and music, or try getting a case of sudden short-term memory loss .


A doodle , Anant Pai and remembering the mid 1990’s

Today (17 September ) was the day that Anant Pai, or as we all remember Uncle Pai, was born, and Google India has actually published a doodle to mark this Occasion.

Anant Pai and his comics Amar Chitra Katha and Tinkle were a real source of awe and inspiration for my generation. When I was a kid I used to trouble my mother every night for a story and she would secretly look into the tinkle books for inspiration. Back then we did not have many TV channels and ones like DD were mostly news channels and broadcast the occasional cartoon, So I literally grew into my Teen years reading Amar Chitra Katha and Tinkle, They did get boring somewhere between 2000 – 2003, But still I really cannot forget those memorable days of reading tinkle for innumerable hours.

The current younger Generation on the other hand has been corrupted by the innumerable number of Cartoons from every channel , and the worst part is that unlike cartoons from my childhood theses are rarely about Life Lessons. Kids today seem to be more interested in over the top heroism and violence . I really despise cartoons like Power Rangers  as they project an image that most of the problems can be solved by killing the main villan and causing as much violence as possible , One could argue that Power Rangers existed in mid 1990’s , but if you think about it they were never broadcast in India at that time , The cartoon I saw as a kid was Jungle Book and other miscellaneous Stories.

Now getting back to the topic , There was a time in the mid 1990’s , I think around 1995 that I saw for the first time a Tinkle comic , and I have to say that I immediately fell in love with it, I would spend hours and hours with my Tinkle and Amar Chirtra Katha Comics. And every month I would pester my dad  to get me the latest issue of the comics, I would secretly smuggle it to school and read it during Lunch times, I would also occasionally get caught reading it in class.

I still vividly remember the colourful stories of Shikari Shambu , Suppandi ,Nasruddin Hodja, etc , They were an abundant source of inspiration back then. Suppandi was one of my favorites , I would find suppandi stories funny even if I had read it for the 100th time, that was the power of those Colourful comics .

Oh I forgot to mention the most Intelligent Characters of them all, Birbal. His stories of wit, humor , combined with intelligence were a real source of exaltation. And most of the time each story had an amazing ending with a really good message . Here are a few that I found : Stories of birbal.Those were literally the Golden years of my education, I learnt a lot and learning was such a pleasurable experience back then , And like all Golden years it did come to an end , But Golden years are the ones that stay in memory for a lifetime . I have to thank Anant Pai for starting something that can never be forgot !!


How to Create a Twitter Like Retweet Links

Twitter is one of the most visited social networking sites , and one of the factors in their success is the intuitiveness of  the user interface .

In this tutorial We are going to learn how to create a twitter like mouse over effect for retweet , favorite links

Twitter mouse over effect

To achieve this effect we are going to be using HTML, CSS and jQuery .

First the HTML :

<div class="<span class=">TweetContainer"></div>
        		<div class="Tweet">
        			<span class="TweetAuthor">
        			<span class="TweetText">
        				I am #Bond, #James Bond ! @JamesBond007
<div class="<span class=">TweetActions"></div>


We create a Container DIV and 2 separate DIVs one for the Tweet and another for the TweetActions. The actual Tweet content is put inside the Tweet DIV and TweetActions contains Favorite and ReTweet .

Next The Styling

                		margin: 15 auto;
                		width: 500px;
                		height: 70px;
                		background: #C7EEFE;
                		padding: 30px;
                		border-radius: 15px;
                		font-family:  Arial,sans-serif
                		border-color: #B7EEFE;
                		position: relative;
                		left: 300px;
                		cursor: pointer

And now comes the jQuery Code

                        	//Hide the Favorite and Retweet Buttons
                        	//Trigger the Mouse over action
                        		 * Show the Retweet and Favorite buttons for the Current
                        		 * Tweet
                        		//Highlight the Current Tweet by changing the background Color

                        	//Trigger the mouse leave action
                        		 * Hide the Retweet and Favorite buttons for the Current
                        		 * Tweet
                        		//Change the background color of the Current Tweet to normal

Putting it all together we get


To get the full Source code just save the Demo Page as html and open it with a text editor .

As always comments and Suggestions are welcome .
Please Post your comments below

Visiting Delhi with a belly (Delhi belly Movie – review)

I have followed the hype over Delhi Belly for some time now , and let me tell you it fully lives up to its expectation . Delhi belly is by far one of the best risky decisions taken by Aamir Khan.

A day before the film released I learnt that there will be 2 versions of the Movie , the original Hinglish Version and a dubbed Hindi Version . Unfortunately I had already booked the tickets so I hoped that the version I would be watching would be the Hinglish one , but as hopes go I ended up with the dubbed Hindi Version which incidentally has toned down dialogues . But to my Surprise I had under estimated my ability to understand Hindi ,  which has greatly Improved since the Time of  3 Idiots , So  I could actually understand more than 95% of the dialogues spoken.

Delhi Belly is the story of Tashi (Imran Khan) and his room mates Arup (Vir Das )  and Nitin (Kunal Roy kapoor)  , who live in an old apartment . Tashi is engaged to Sonia (Shenaz Treasurywala) . Tashi is a journalist and Nitin is his photographer while Arup is a Cartoonist .

These blokes lead an average life until they get caught up in a mess with a smuggling syndicate lead by [Vijay Razz] .

In the mean time Tashi starts falling in love with a special Correspondent Menaka (Poorna Jagannathan) , while Nitin gets the worst food poisoning of his life by eating tandoori chicken from a road side vendor , and Arup gets dumped by his Girlfriend who plans to get married to an NRI .

What happens next is a series of events which are extremely funny , entertaining , and some thing which is not to be missed . But take this with a grain of Salt because this is not the usual brand of humour that we have come to expect from Bollywood  , The humour in this film is either extremely  brilliant or overly offensive depending on how you look at .

This film comes with a good number of pros , first this is a very new kind of film in the lines of Lock Stock and Two Smoking Barrels , Snatch , and The  Hangover  , secondly this kind of film is very new to Indian Cinema , and Finally No other currently playing film will make you laugh so much .

There comes only one Con with this film , This film is not for Family Audience and children , This film is not for those who get easily offended , this is not those people who have as sense of hypocritical morality , and Most Importantly it’s not for Parents !!

Technically also this film is brilliant Art direction , Editing , Music , all these deserve a special mention .

In the Acting department , the three main roles are played extremely well by the actors getting into the skin of the character  , Shenaz  and Poorna do their part well , and Vijay Razz as the Smuggling Gang leaders is brilliant along with the Guy who Says “(Knocking on a hotel room door )Sir ,Loondrry”.

Dialogues in the film are exceptional which is one of the main reason this movie works .

Director Abhinay Deo and writer Akshat Varma have created a movie which easily connects with its tare get audience and no one else , A film which is does not try to hide its intentions behind cheeky double meaning dialogues , there is generous usage of Expletives from both English and hindi.

On the whole Delhi belly is an amazing 1 hr  30 minute ride ,  which is not spoilt by any unnecessary breaks like an interval or song sequence , and a film which should not be missed if you can stomach it .

Typing தமிழ் (Tamil) on Ubuntu Linux

To type a indic language on Linux you need to do some work before you get it working and before we start I am assuming that you are using ubuntu Linux 10.04 or higher .

The first thing you need is to install ibus 

so to install ibus open terminal and type

sudo apt-get install ibus

sudo apt-get install ibus-m17n

after installing ibus and m17n go to System->Administration->Language Support in the Gnome menu

Select keyboard input system as ibus

Click on Install/Remove Languages -> Select Tamil -> Select all the Components ->Apply the changes.

Then go to System->Preferences->Keyboard Input Methods 

Goto Input Method Tab , Select an Input method and then choose Tamil -> Tamil-phonetic and click Add

Enable Show icon on System tray 

then your preferred shortcut keys .

Choose Tamil from the keyboard icon in the notification area

and now you can type தமிழ் (Tamil) !!

நண்றி வணக்கம் !


Post you comments and Suggestions in the section below .

I am Officially Human !!

96 Hours :

Its been exactly been 96 hours since Ubuntu Linux 10.10 (Maverick Meerkat ) was installed in a dual boot Setup on my Laptop ,

and I am proud to say that I have booted into windows only twice in that time and that too only temporarily. I have been using a Microsoft OS as my Primary Operating System form 1998-99 , that was when I convinced my dad to bring Home his old Office Computer so I could Use it

The last time I installed Ubuntu was way back in its Gutsy Gibbon(7.10) days , back then I had Windows xp on one Hard disk and Ubuntu on another Hard disk  so each time I wanted to switch OS I had to change the Hard disks , OK Enough History  now Lets Get Down To business .

The Awesomeness that followed :

Not much has changed really ,I still use firefox and chrome for browsing , VLC for videos …. etc .

But wait the waiting time has decreased , I mean the boot time has some how magically dropped , well may be thats because I am using a newly installed OS .

Then there is the part about having a Cooler looking Desktop !!

I was surprised  when I found out that I had almost all the features of Windows 7 Aero Interface (Including transparent Window borders ) Though they  function a bit differently in Ubuntu and as usual you do need a Capable Graphics card to handle it , but if you don’t you can just as easily turn them off .

What about applications I asked myself , I knew that there were open source alternatives to many windows applications or I could count on WINE to run my apps  , Well my Knowledge turned out to be true . Even the occasional Counter Strike game that I play , works Fine on WINE .

I forgot to mention the standard procedure everyone performs immediately  after installing Windows  , Installing Drivers , then Installing an Anti-Virus Program  , well as you have probably guessed by now I did skip those parts because there weren’t needed . I did Have to Download Updates though .

The Not-So Awesomeness that Followed :

The first thing tried to do after installing Ubuntu was Play a movie  , but due to some lame ethical and copyright reasons it refused to play Mp3 , AVI (Divx , Xvid)  , MKV (H.264 , X264 ) , Mp4 , Flv … and the other commonly  used formats .

Youtube was also on the list as Flash Player was also not present Out of the Box .

But the solution was really simple , install ubuntu-restricted-extras .

The AWESOME desktop that you see above doesn’t come out of the box  , though the default desktop still looks good .

Finally :

In the past 96 hours I have not missed Windows one bit , but lets see how Ubuntu holds up in the coming months .