eniallator

CodeGolf: Every Possible Order Of String's Chars

Jan 19th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. **New Challenge:** Every possible order of a string's characters
  2.  
  3. **Description:** Write a function that receives a string and output every possible order that the characters can be arranged in. The output has to be a string with combinations being comma separated. Leading/trailing commas are allowed.
  4.  
  5. **Important Note:** As long as you have all the combinations with no duplicates, the order that they are presented in, in the output string does not matter.
  6.  
  7. **Warning:** The amount of combinations is the factorial of the length of the string, so test with small strings!
  8.  
  9. **Examples:**
  10. ```
  11. input -> output
  12.  
  13. "" -> ""
  14. "l" -> "l"
  15. "lm" -> "lm,ml"
  16. "lma" -> "lma,lam,mla,mal,alm,aml"
  17. "lmao" -> "lmao,lmoa,lamo,laom,loma,loam,mlao,mloa,malo,maol,mola,moal,almo,alom,amlo,amol,aolm,aoml,olma,olam,omla,omal,oalm,oaml"
  18. ```
Advertisement
Add Comment
Please, Sign In to add comment