Generate All String Character Permutations

Published by Sinomede in

Create a function to generate all string character permutations.

Examples

Permutations("AB") ➞ "AB BA"

Permutations("CD") ➞ "CD DC"

Permutations("EF") ➞ "EF FE"

Permutations("NOT") ➞ "NOT NTO ONT OTN TNO TON"

Permutations("RAM") ➞ "AMR ARM MAR MRA RAM RMA"

Permutations("YAW") ➞ "AWY AYW WAY WYA YAW YWA"

Notes

Sort your results in alphabetical order before returning them.

Watch a quick demo on how Edabit works.