| Problem 153 - Permalex, Explanations |
One way to do it is to order it, then successively compute the next one until the string matches the input.
You can reuse code from the problem 146.
If you are in trouble with the multi-entry input, read my how to read input.
Thus the string `acab' can be characterised in this sequence as 5.
Write a program that will read in a string and determine its position
in the ordered sequence of permutations of its constituent characters.
Note that numbers of permutations can get very large; however we
guarantee that no string will be given whose position is more than
.
Input will consist of a series of lines, each line containing one string. Each string will consist of up to 30 lower case letters, not necessarily distinct. The file will be terminated by a line consisting of a single #.
Output will consist of a series of lines, one for each line of the input. Each line will consist of the position of the string in its sequence, right justified in a field of width 10.
bacaa abc cba #
15
1
6