Anagram

Joshua Muskovitz joshm at taconic.net
Wed Jan 23 18:58:22 EST 2002


[ideas for computing factorial(n) where n = length of some string]

how about:

import operator
reduce(operator.mul, xrange(1, len(s)+1), 1)

This has no recursion or memory problems, I believe.  If you don't like the
import, you could substitute a lambda function:

reduce(lambda x,y: x*y, xrange(1, len(s)+1), 1)

--
# Joshua Muskovitz
# joshm at taconic.net
def lyyrs(sig): return '-'.join(sig.split()+["ly y'rs"])
lyyrs('Hire me!  I need the work!')




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list