Ejemplo n.º 1
0
        public void HeapsAlgorithmTest(string permuatation)
        {
            var heapsResult = Permutations.HeapsAlgorithm(3, new[] { "1", "2", "3" }).Select(x => string.Join(",", x)).ToList();

            Assert.Equal(6, heapsResult.Count);
            Assert.Contains(permuatation, heapsResult);
        }
Ejemplo n.º 2
0
        public void AbdulsAlgorithm()
        {
            var abdulResult =
                Permutations.AbdulsAlgorithm(
                    new List <List <object> >()
            {
                new List <object>()
                {
                    "1", "2"
                },
                new List <object>()
                {
                    "1", "2", "3"
                },
                new List <object>()
                {
                    "1", "2"
                }
            });
            var results = abdulResult.Select(x => string.Join(',', x)).ToList();

            Assert.True(results.Distinct().Count() == results.Count);
            Assert.Equal(12, results.Count);
            Assert.Contains("1,1,1", results);
        }
Ejemplo n.º 3
0
        public void AbdulsAlgorithm_AllCombinationsTest(string combinationAsString)
        {
            var abdulResult =
                Permutations.AbdulsAlgorithm(
                    new List <List <object> >()
            {
                new List <object>()
                {
                    "1", "2"
                },
                new List <object>()
                {
                    "1", "2", "3"
                },
                new List <object>()
                {
                    "1", "2"
                }
            });
            var results = abdulResult.Select(x => string.Join(',', x)).ToList();

            Assert.Contains(combinationAsString, results);
        }