Пример #1
0
        public void TestLastOneRule()
        {
            const string str =
                "2...7..38\n" +
                ".....6.7.\n" +
                "3...4.6..\n" +
                "..8.2.7..\n" +
                "1.......6\n" +
                "..7.3.4..\n" +
                "..4.8...9\n" +
                ".6.4.....\n" +
                "91..6...2\n";
            var grid = Grid.Load(str);

            Processor.AdjustCells(grid.Columns[0]);
            Processor.AdjustCells(grid.Columns[1]);
            Processor.AdjustCells(grid.Columns[2]);
            Processor.AdjustCells(grid.Rows[6]);
            Processor.AdjustCells(grid.Rows[7]);
            Processor.AdjustCells(grid.Rows[8]);


            var area = grid.Blocks[6];

            Processor.AdjustCells(area);

            var cell = grid.Cells[7, 0];

            Assert.True(cell.IsEmpty);
            var res = Processor.LastOneRule(area);

            Assert.True(res);
            Assert.True(cell.IsCompleted);
        }
Пример #2
0
        public void TestArrange()
        {
            var cells = new[]
            {
                new Cell(0, 0, 4),
                new Cell(0, 0, 5, 9),
                new Cell(0, 0),
                new Cell(0, 0),
                new Cell(0, 0),
                new Cell(0, 0),
                new Cell(0, 0, 9),
                new Cell(0, 0, 3),
                new Cell(0, 0, 8),
            };

            var res = Processor.AdjustCells(cells);

            Assert.True(res);

            Assert.Equal(5, cells[1].Value);
            Assert.True(cells[2].EqualVariants(new [] { 1, 2, 6, 7 }));
            Assert.True(cells[3].EqualVariants(new [] { 1, 2, 6, 7 }));
            Assert.True(cells[4].EqualVariants(new [] { 1, 2, 6, 7 }));
            Assert.True(cells[5].EqualVariants(new [] { 1, 2, 6, 7 }));
        }