![]() / Generator of all permutations of an array of anything. For the string s of length n, for any k from 0 to n - 1 inclusive, the following modifies s to provide a unique permutation (that is, different from those. Linq: 36288000 items in 50051 millisecs using System Just as comparison of this with a Linq implementation for 10! (code included): According to Heap's algorithm in Wikipedia, it should be the fastest. If performance and memory is an issue, I suggest this very efficient implementation. Static string swap(int currentPosition, int targetPosition, string temp)Īrr = arr If (!first.Contains(init s1)) first.Add(init s1) įor (int i = 1 i generateWords(string test) String restOfbody = s.Substring(1, s.Length - 1) I found the pseudocode on : makePermutations(permutation)
0 Comments
Leave a Reply. |