|
|||
Knuth’s PermutationThere are some permutation generation techniques in Donald E. Knuth’s book The Art of Computer Programming – Volume 1. One of the processes is as follows:
For each permutation A1, A2, …,
An-1, form n others by inserting a character
n in all possible places, obtaining Following this rule, you have to generate all permutations for a given set of characters. All the given characters will be different and their number will be less than 10 and they all will be alphanumeric characters. This process is recursive, and you will have to start the recursive call with the first character and keep inserting the other characters in order. The sample input and output will make this clear. Your output for the sample input should exactly match the sample output. Input SpecificationThe input contains several lines. Each line will be a sequence of characters.There will be less than ten alphanumeric characters in each line. The input will be terminated by EOF. Output Specification
For each line of input, generate all permutations of those characters. The ordering of
the input characters is very important for the output. That is, the permutation
sequences for Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |