Created
December 6, 2016 13:29
-
-
Save Zabaa/dccac65e36c7a5d178f60a56feaa30e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Permutation | |
{ | |
public static IEnumerable<string> GetPermutations(string s) | |
{ | |
if (s.Length > 1) | |
return from ch in s | |
from permutation in GetPermutations(s.Remove(s.IndexOf(ch), 1)) | |
select string.Format("{0}{1}", ch, permutation); | |
else | |
return new string[] { s }; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment