On 04/19/2013 03:07 PM, Alan Gauld wrote:
On 19/04/13 22:19, Chetan Sai wrote:

I'm a beginner in Python Programming.

The language isn't really the issue here the issue is the algorithm.
So how would you do it manually with a paper and pen? (forget about
fetching the list from the URL for now)

One possibility is to use sets (Python has a set data type).
create a set of words.
Now create a set of reversed words.
The intersection of those sets is the set of words which
also have a reversed pair.

print the intersection set.

The gotcha with this approach is the border case of self paired words that aren't pairs. (pop,wow,mom,etc)

I got 94 distinct pairs. Which is a better result than the 124.5 pairs I got the first pass through.

Emile



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to