Exemplo n.º 1
0
        public void ExactCoverTest()
        {
            var sut   = new DancingLinks();
            var xKeys = sut.BuildSetMatrixKeys(4);
            var y     = sut.BuildSubsetMatrix(4, 2, 2);

            var x = sut.ExactCover(xKeys, y);

            x.Dump(TestContext.WriteLine, $"Dumping x, item count = {x.Count}");
        }
Exemplo n.º 2
0
        public void BuildSetMatrixKeysTest1()
        {
            var sut = new DancingLinks();

            var actualXKeys = sut.BuildSetMatrixKeys(4);

            Assert.AreEqual(64, actualXKeys.Count);

            actualXKeys.Dump(TestContext.WriteLine, $"Dumping actualXKeys, item count = {actualXKeys.Count}");
        }
Exemplo n.º 3
0
        public void LoadCaseToSolveTest()
        {
            var grid = new[]
            {
                new[] { 1, 0, 3, 4 },
                new[] { 3, 4, 1, 2 },
                new[] { 2, 1, 4, 3 },
                new[] { 4, 3, 2, 1 }
            };

            var sut   = new DancingLinks();
            var xKeys = sut.BuildSetMatrixKeys(4);
            var y     = sut.BuildSubsetMatrix(4, 2, 2);
            var x     = sut.ExactCover(xKeys, y);

            sut.LoadCaseToSolve(grid, x, y);

            x.Dump(TestContext.WriteLine, $"Dumping x, item count = {x.Count}");
        }