Skip to main content
Title.
Link
Mateen Ulhaq
  • 27.9k
  • 21
  • 121
  • 155

How todo I generate all permutations of a list?

edited title
Link
funnydman
  • 11.8k
  • 4
  • 51
  • 67

How to generate all permutations of a list?

Shorten.; edited tags
Source Link
Mateen Ulhaq
  • 27.9k
  • 21
  • 121
  • 155

How to generate all permutations of a list?

How do youI generate all the permutations of a list in Python, independently of the type of elements in that list?

  For example:

permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] 

How to generate all permutations of a list?

How do you generate all the permutations of a list in Python, independently of the type of elements in that list?

  For example:

permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] 

How to generate all permutations of a list

How do I generate all the permutations of a list? For example:

permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] 
Edited question title and removed language tag.
Link
martineau
  • 124.1k
  • 29
  • 181
  • 319
Loading
deleted 261 characters in body
Source Link
jonrsharpe
  • 123.3k
  • 31
  • 277
  • 488
Loading
Question Protected by CommunityBot
deleted 6 characters in body
Source Link
Remi Guan
  • 22.5k
  • 17
  • 68
  • 90
Loading
minor spelling fixes and an update (Python 2.6 has been and gone)
Source Link
Alex Riley
  • 178.1k
  • 46
  • 274
  • 247
Loading
This needs a permutation tag in my opinion.
Link
Shashank
  • 13.9k
  • 5
  • 39
  • 63
Loading
edited tags
Link
Prashant Kumar
  • 23.2k
  • 14
  • 52
  • 64
Loading
edited tags
Link
Jacob Krall
  • 29k
  • 6
  • 69
  • 76
Loading
included the best answers in the question body
Source Link
Ricardo Reyes
  • 13.9k
  • 4
  • 29
  • 19
Loading
Source Link
Ricardo Reyes
  • 13.9k
  • 4
  • 29
  • 19
Loading