public void UnrankSingletonString() { string s = "x"; int n = s.Length; long r = KevinMath.LongRandom(0, KevinMath.Factorial(n) - 1, new Random()); int[] pi = RankUnrank.InitIndexArray(n); RankUnrank.Unrank(n, r, pi); string ps = GetPermString(s, pi); Console.WriteLine(string.Format("r:{0} s:{1} p:{2}", r, s, ps)); }
public void UnrankStringLenThree() { string s = "xyz"; int n = s.Length; Console.WriteLine(string.Format("s:{0}", s)); for (int r = 0; r < KevinMath.Factorial(n); r++) { int[] pi = RankUnrank.InitIndexArray(n); RankUnrank.Unrank(n, r, pi); string ps = GetPermString(s, pi); Console.WriteLine(string.Format("r:{0} p:{1}", r, ps)); //int[] inv = RankUnrank.GetInverseArray(pi); //long rank = RankUnrank.Rank(n, pi, inv); //Assert.AreEqual(r, rank); } }