This tool returns successive r length permutations of elements in an iterable.
If r is not specified or is None, then r defaults to the length of the iterable, and all possible full length permutations are generated.
Permutations are printed in a lexicographic sorted order. So, if the input iterable is sorted, the permutation tuples will be produced in a sorted order.
You are given a string S.
Your task is to print all possible permutations of size k of the string in lexicographic sorted order.
A single line containing the space separated string S and the integer value k.
The string contains only UPPERCASE characters.
Print the permutations of the string S on separate lines.
All possible size 2 permutations of the string "HACK" are printed in lexicographic sorted order.