The Permutation Element method.
public Permutation Element(BigInteger k)
if (k >= Factorial(this.n))
throw new Exception("k too large in Element");
Permutation result = new Permutation(this.n);
int factoradic = new int[this.n]; // factoradic of k
for (int j = 1; j <= n; ++j) // note: skip 
factoradic[n - j] = (int)(k % j); // remainder always an int
k /= j;
for (int i = 0; i < n; ++i)
result.data[n - 1] = 1; // last value set to 1
for (int i = n - 2; i >= 0; --i)
result.data[i] = factoradic[i]; // copy factoradic
for (int j = i + 1; j < n; ++j) // inc all values to right . .
if (result.data[j] >= result.data[i]) // that are < factoradic
for (int i = 0; i < n; ++i) // make result 0-based
About the Author
Dr. James McCaffrey works for Microsoft Research in Redmond, Wash. He has worked on several Microsoft products including Azure and Bing. James can be reached at [email protected].
User experience expert Debbie Levitt provided some saucy answers about an upcoming Visual Studio Live! presentation with an even saucier title: Fast Focus: WTF UX - UX Research and Design AMA.
Developers can now sign up for a private preview of enhanced chat capabilities coming to GitHub Copilot, the "AI pair programmer" that works in the Visual Studio 2022 IDE and in Visual Studio Code.
With advanced generative AI systems reshaping software development, Microsoft's Mads Kristensen detailed the many ways AI will improve coding in Visual Studio.
With Google recently releasing a generative AI-powered search bot called Bard to rival Microsoft's "new Bing" search experience, we put both to the test, feeding them identical questions about Visual Studio and .NET.
GPT-4, the advanced generative AI model from Microsoft partner OpenAI, is now powering the new GitHub Copilot X and the Azure OpenAI Service.
> More Webcasts