[Tutor] A small math puzzle [recreational Python]
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Sat, 5 Jan 2002 01:53:04 -0800 (PST)
Hi everyone,
I ran across this puzzle while browsing the the 'alt.math.undergrad'
newsgroup. I thought it might make a fun programming exercise, so here's
my paraphrase of the puzzle:
A "rearrangement without fixed letters" of a given word is a mixup of the
letters so that, if one were to overlap the original with the
rearrangement, no letters should match. For example, given the word:
'TERESA'
here are a two "rearrangements without fixed letters":
['RTESAE', 'SATREE']
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!