[Tutor] Obtaining various combinations of a given word
John Fouhy
john at fouhy.net
Wed Jul 30 01:56:32 CEST 2008
On 30/07/2008, sai krishna <sparkignited at gmail.com> wrote:
> I wanted to print out all the combinations of a given word.
A thought for you:
Let's say you want to find permutations of the string 'abcd'. Some of
those permutations will start with 'a' -- how many? Can you list all
the permutations starting with 'a'? Do you see any connection between
that list and your solution for n == 3?
(hint: the following is a function for computing factorials. Do you
understand it?
def fac(n):
if n == 0:
return 1
else:
return n*fac(n-1)
)
(also, another thought for you, once you've solved this problem: what
answer would you expect for the string 'aaa'?)
--
John.
More information about the Tutor
mailing list