Generating a password by switching letters

53 Views Asked by At

Stefan creates a password by switching his names's letters two by two,getting the password "fanest".How many switches did he make?
I don't know how to approach this,I simply tried making a few switches by hand,but I doubt this helps.
EDIT: After the discussion in the comments, I believe that we need to find the minimum number of moves and "two by two" means blocks of two letters.

1

There are 1 best solutions below

2
On BEST ANSWER

Programmatically generating the graph of all possible passwords achievable from 'stefan' by repeatedly swapping two blocks of two characters each produces $360$ distinct strings (half of the permutations of 'stefan'). The string 'fanest' is not among these strings.

Programmatically generating the graph of all possible passwords achievable from 'stefan' by repeatedly swapping two single characters produces $720$ distinct strings (all of the permutations of 'stefan'). These strings require at most $5$ swaps. The string 'fanest' is among those strings that require $5$ swaps.