+ 14
Python challenge 2
The next Python challenge I am making. What to do: given input list n, write a function that shows all the possible permutations in the form of a 2D-list. The challenge: Don't use powerful modules! Example: https://code.sololearn.com/cVnmWL3uOE5x/?ref=app 2D lists: https://code.sololearn.com/c1xs8n03Th96/?ref=app
10 odpowiedzi
+ 9
Nice can make it for lists?
+ 8
Maybw for that use list(set()) but use iteration.
+ 7
So given to list [1,1,1,1,1], there are still 120 permutations that should be returned?
+ 6
@$Vengat It returns 1 or 1 list of 1s, the one passed to it? And why would it not return all possibilities/permutations? Like in your not to do code, it does.
+ 6
@Baptiste No, permutations are all possibilities regardless of repeats. Combinations aren't, so if that is supposed to be the output, then it is combinations (how many distinctly different ways can something happen) and not permutations (all the possible ways something can happen). Just saying. ; )
+ 5
No. It returns 1.
And yeah try recursion
+ 5
I wrote this some time ago. It is almost same to what u ask
You Enter a string and all possible permutations are returned
And Yes I did not use any powerful module
https://code.sololearn.com/cm9kq0LPTei7/?ref=app
+ 3
It has not a good complexity though ^^'
https://code.sololearn.com/cRZupotoCP0k/?ref=app
+ 3
@JG, returning [[1,1,1,1,1]] in your example is all the permutations you can do, all the 119 others are just copies of this one
+ 1
Here you go. I used Heap's Algorithm recursively to do this, and added a check to ignore all duplicates if they come up based on a randomly loaded array based on user input.
https://code.sololearn.com/cp3X62Tv6X11/?ref=app