[Tutor] A small math puzzle [recreational Python]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat, 5 Jan 2002 12:22:28 -0800 (PST)


On Sat, 5 Jan 2002, Lloyd Hugh Allen wrote:

> Danny Yoo wrote:
> > However, here's an example that is a rearrangement but doesn't work
> > because it has a fixed letter:
> > 
> >     'TRESAE'
> >      ^
> > 
> > In this example, the 'T' makes this rearrangement inacceptable, since
> > 'TERESA' itself begins with a 'T' too.
> > 
> > The puzzle is to write a program that counts all the possible
> > rearrangements without fixed letters.
> > 
> > Have fun!
> 
> Is it necessary to actually construct the list of rearrangements, or
> do you just want a function that will compute how many rearrangements
> exist?

If you can think of a way to do it without actually generating the
rearrangements, that would be great!