Playing with Python: Starting off with anagrams

I’m really into Python this summer, and thought I might share some of my work. I started off with a (simple enough) web application to connect to MySQL on Fedora 12, trying to make a cricket statistics site. It went off pretty well, but I got pretty bored and went off to do an Anagram generator. This morning I started off, with a basic tool to check if two strings are anagrams of one another.

The flow I thought of was:

1. Remove spaces from the strings, and sort them in ascending order.

2. Compare the sorted strings to see if they are equal. The two steps can be done in a single line.


return sorted(list(in1)) == sorted(list(in2))

This will show if the two strings are anagrams of each other.

I need to create a dictionary of words, and then think of a way to get the major anagram generation part going. I hope to complete that over the weekend. I also hope to check my code on Python 2 and 3, using Fedora 13’s parallel installable stacks.

Advertisements

Why Mission 2020 will fail.

We all know about the great Dr. Abdul Kalam’s vision for India to become a developed nation by 2020. We’re just 11 years away from that deadline, and what have we done in the past decade moving in that direction? We’ve had three elections, but none of the government seems to figure out and do something about the root causes of stagnation. Yes, there have been several development schemes, but do they deliver to the people? No, sir, the politicians swell their bellies with that money which needs to go and reach the people. Corruption! Unrelentlessly pursued and has become a normal occurrence in our day to day lives. This ought to change, but who is to start the change?

I’ve heard of, read about and seen people shamelessly demanding bribe(Ah, they prefer to call them tokens of appreciation!) even from the poorest of the poor. If this has to stop, people need to change our outlook. Sure, if someone really performs well in their job, you can reward their hard work. But you don’t need to reward  them to carry out their duties! Aung San Suu Kyi once rightly remarked: It is not power that corrupts but fear. Fear of losing power corrupts those who wield it and fear of the scourge of power corrupts those who are subject to it.

Our politicians have become so used to power – its misuse and abuse – that they can’t live without it. OK! I get the point, why can’t they just exit earth and continue their work somewhere? Last I heard, they need lots of people capable of cheating and boring out others in hell.

We need to have a young and dynamic government, and all the old fellows need to accept moral responsibility for the current state of affairs and give up. Yes sir, morality. Many politicians don’t know or have never heard this word. The Oxford English Dictionary defines it as:

morality
1    principles concerning the distinction between right and wrong or good and bad behaviour. A system of values and moral principles.
2    the extent to which an action is right or wrong.

Now, another thing politicians do is pamper – especially those parts of the societies who are gullible and are always looking out for things to happen rather than making things happen. Well, they are the so called minorities. I don’t deny there are some sections that are really pitiful and could do with some pampering. But the reality is that, if over six decades of pampering has not helped them grow, nothing else will. Leave them on their own, and let them rise on their own legs. This surely is unthinkable in India. Reason: votebank politics. Since the middle class has better things to do than go out and vote for people who’d never care to think of the voters’ welfare. Now that’s another thing that needs change.

India is becoming a country that could have been the superpower, but was not to be. If these evils and many others are not weeded out, then the saint Kalam’s dreams wouldn’t be a reality even in 2120.