Write a recursive function to print all permutations of given digits(1,2,3,4,...,N) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Write a recursive function to print all permutations of given digits(1,2,3,4,...,N)

Can anyone code this ?

13th Oct 2017, 5:27 AM
Shakil
Shakil - avatar
9 Answers
+ 11
i like the challenge //will make code later ☺ (java)
13th Oct 2017, 12:20 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
Explanation?
13th Oct 2017, 5:39 AM
Meharban Singh
Meharban Singh - avatar
+ 3
What do you mean by "permutations'. Kindly give a sample input and expected output
13th Oct 2017, 6:31 AM
Meharban Singh
Meharban Singh - avatar
+ 3
ook
13th Oct 2017, 8:42 AM
Meharban Singh
Meharban Singh - avatar
+ 2
I meant could you explain what you want?
13th Oct 2017, 6:11 AM
Meharban Singh
Meharban Singh - avatar
+ 1
yes, please!
13th Oct 2017, 5:59 AM
Shakil
Shakil - avatar
+ 1
I need the code of that question
13th Oct 2017, 6:18 AM
Shakil
Shakil - avatar
+ 1
input: 1,2,3 output: 123 132 213 231 312 321
13th Oct 2017, 7:03 AM
Shakil
Shakil - avatar
+ 1
I think you want like this but it is Python and using generator. I saw it on internet. def permu(x): if len(x) == 1: yield x else: for i in range(len(x)): for p in permu(x[:i] + x[i+1:]): yield [x[i]] + p print(list(permu([1,2,3])))
13th Oct 2017, 11:55 AM
Ferhat Sevim
Ferhat Sevim - avatar