Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            List <List <int> > result = Permutations.findPermutations(new int[] { 1, 3, 5 });

            Console.WriteLine("Here are all the permutations: " + result);
        }
Пример #2
0
        public void Benchmark_duplicates()
        {
            var result = Permutations.Of("aaaabbbbcccc");

            Assert.That(result.ToArray().Contains("ccccbbbbaaaa"));

            Assert.That(result.Count(), Is.EqualTo(34650)); // 12!/(4!)^3;
        }
Пример #3
0
        public void Benchmark()
        {
            var result = Permutations.Of("012345678");

            Assert.That(result.ToArray().Contains("876543210"));

            Assert.That(result.Count, Is.EqualTo(362_880)); // 9!
        }
Пример #4
0
        private static void GetPermutations()
        {
            List <int> integers = new List <int> {
                1, 2, 3
            };

            Permutations <int> p = new Permutations <int>(integers);

            foreach (IList <int> item in p)
            {
                string line = string.Join(",", item);
                Console.WriteLine(line);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            Stopwatch MyTimer = new Stopwatch();

            MyTimer.Start();
            Permutations.PrintList(Permutations.SinglePermutations("a"));
            Console.WriteLine();
            Permutations.PrintList(Permutations.SinglePermutations("ab"));
            Console.WriteLine();
            Permutations.PrintList(Permutations.SinglePermutations("abcc"));
            MyTimer.Stop();
            Console.WriteLine(MyTimer.ElapsedMilliseconds.ToString("00:00:00"));
            Console.ReadKey();
        }
Пример #6
0
 public void Duplicates_are_ignored()
 {
     Assert.That(Permutations.Of("aab"),
                 Is.EquivalentTo(new [] { "aab", "aba", "baa" }));
 }
Пример #7
0
 public void Returns_correct_permutations(string input, string[] expected)
 {
     Assert.That(Permutations.Of(input), Is.EquivalentTo(expected));
 }