Find the permutations
Problem to find the possibility of the combination based on the given input and k value.
Example-1:
Input : n = "123" k = 3 Output : 123 132 213 231 312 321
Example-2:
Input : n = "123" k = 2 Output : 12 13 21 23 31 32
Solution
from itertools import permutations n = "123" k=3 d = list(permutations(n,k)) for i in range(len(d)): print("".join(d[i]),end=" ")
Output
123 132 213 231 312 321