Ejemplo n.º 1
0
        public void NumberPermuterShouldWorkForThreeNumbers()
        {
            var output    = SimpleNumberPermuter.GeneratePermutationsLists(3);
            var predicted = new[]
            {
                new[] { 1, 2, 3 }.ToList(),
                new[] { 1, 3, 2 }.ToList(),
                new[] { 2, 1, 3 }.ToList(),
                new[] { 2, 3, 1 }.ToList(),
                new[] { 3, 1, 2 }.ToList(),
                new[] { 3, 2, 1 }.ToList()
            }.ToList();

            output.Count().Should().Be(predicted.Count());

            IEnumerable <bool> x = output.Zip(predicted, ((o, p) => o.SequenceEqual(p)));

            if (x.All(val => val))
            {
                Assert.Pass();
            }
            else
            {   //This test is innaccurate, but gives a much more debuggable output.
                predicted.Should().Equal(output);
            }
        }
Ejemplo n.º 2
0
 public IEnumerable <DelacorteGrid> GenerateAllGridsFromScratch()
 {
     foreach (var permutation in SimpleNumberPermuter.GeneratePermutationsLists(N * N))
     {
         yield return(new DelacorteGrid(ListToGridByTripleLoop(permutation)));
     }
 }
Ejemplo n.º 3
0
        public IEnumerable <DelacorteGrid> GenerateAllGridsGivenPartialGrid(DelacorteGrid startingGrid)
        {
            List <int> remainingValuesToBeFilled = startingGrid.IdentifyUnusedValues();

            foreach (var permutation in SimpleNumberPermuter.GeneratePermutationsOfList(remainingValuesToBeFilled))
            {
                yield return(startingGrid.FillToCreateNewGrid(permutation));
            }
        }
Ejemplo n.º 4
0
 static void PermuteTimeBenchmark()
 {
     for (int i = 0; i < 10; i++)
     {
         var x = new Stopwatch();
         x.Start();
         List <int> y = null;
         foreach (var force in SimpleNumberPermuter.GeneratePermutationsLists(10))
         {
             y = force.ToList();
         }
         Console.WriteLine(y);
         x.Stop();
         Console.WriteLine(x.ElapsedMilliseconds);
     }
 }