コード例 #1
0
ファイル: PermutorTest.cs プロジェクト: roddickchen/NCDK
        public void CountGeneratedPermutations()
        {
            int      size     = 4;
            Permutor permutor = new Permutor(size);
            int      count    = 1; // the identity permutation is not generated

            while (permutor.HasNext())
            {
                permutor.GetNextPermutation();
                count++;
            }
            Assert.AreEqual(Factorial(size), count);
        }
コード例 #2
0
ファイル: PermutorTest.cs プロジェクト: roddickchen/NCDK
        public void GetCurrentPermutationTest()
        {
            int      size     = 4;
            Permutor permutor = new Permutor(size);
            bool     allOk    = true;

            while (permutor.HasNext())
            {
                permutor.GetNextPermutation();
                int[] current = permutor.GetCurrentPermutation();
                if (ArrayElementsDistinct(current))
                {
                    continue;
                }
                else
                {
                    allOk = false;
                    break;
                }
            }
            Assert.IsTrue(allOk);
        }