当前位置: 首页>>代码示例>>C#>>正文


C# Grid.GetAlternatives方法代码示例

本文整理汇总了C#中Grid.GetAlternatives方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.GetAlternatives方法的具体用法?C# Grid.GetAlternatives怎么用?C# Grid.GetAlternatives使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grid的用法示例。


在下文中一共展示了Grid.GetAlternatives方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RepeatedGetAlternatives

        public void RepeatedGetAlternatives()
        {
            Grid grid = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 2, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 3, 0, 8, 1, 4, 2, 9, 6, 5 },
                new[] { 0, 0, 0, 5, 3, 0, 0, 0, 0 },
                new[] { 4, 5, 2, 9, 6, 8, 1, 7, 0 },
                new[] { 0, 0, 0, 0, 7, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 9, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 8, 0, 0, 0, 0 },
            });

            Grid step1 = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 2, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 3, 7, 8, 1, 4, 2, 9, 6, 5 },
                new[] { 0, 0, 0, 5, 3, 0, 0, 0, 0 },
                new[] { 4, 5, 2, 9, 6, 8, 1, 7, 0 },
                new[] { 0, 0, 0, 0, 7, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 9, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 8, 0, 0, 0, 0 },
            });

            Grid step2 = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 2, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 3, 7, 8, 1, 4, 2, 9, 6, 5 },
                new[] { 0, 0, 0, 5, 3, 0, 0, 0, 0 },
                new[] { 4, 5, 2, 9, 6, 8, 1, 7, 3 },
                new[] { 0, 0, 0, 0, 7, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 9, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 8, 0, 0, 0, 0 },
            });

            Grid step3 = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 2, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 5, 0, 0, 0, 0 },
                new[] { 3, 7, 8, 1, 4, 2, 9, 6, 5 },
                new[] { 0, 0, 0, 5, 3, 0, 0, 0, 0 },
                new[] { 4, 5, 2, 9, 6, 8, 1, 7, 3 },
                new[] { 0, 0, 0, 0, 7, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 9, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 8, 0, 0, 0, 0 },
            });

            Grid step4 = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 2, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 1, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 5, 0, 0, 0, 0 },
                new[] { 3, 7, 8, 1, 4, 2, 9, 6, 5 },
                new[] { 0, 0, 0, 5, 3, 7, 0, 0, 0 },
                new[] { 4, 5, 2, 9, 6, 8, 1, 7, 3 },
                new[] { 0, 0, 0, 0, 7, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 9, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 8, 0, 0, 0, 0 },
            });

            Grid[] alternatives = grid.GetAlternatives().ToArray();

            Assert.AreEqual(1, alternatives.Length, "Step 1 alternatives");
            Assert.AreEqual(step1, alternatives[0], "Step 1");

            alternatives = alternatives[0].GetAlternatives().ToArray();

            Assert.AreEqual(1, alternatives.Length, "Step 2 alternatives");
            Assert.AreEqual(step2, alternatives[0], "Step 2");

            alternatives = alternatives[0].GetAlternatives().ToArray();

            Assert.AreEqual(1, alternatives.Length, "Step 3 alternatives");
            Assert.AreEqual(step3, alternatives[0], "Step 3");

            alternatives = alternatives[0].GetAlternatives().ToArray();

            Assert.AreEqual(1, alternatives.Length, "Step 4 alternatives");
            Assert.AreEqual(step4, alternatives[0], "Step 4");
        }
开发者ID:aistrate,项目名称:SudokuSolver,代码行数:87,代码来源:GridTests.cs

示例2: GetAlternatives

        public void GetAlternatives()
        {
            Grid grid = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 6, 0, 8, 0, 4, 2, 0, 3, 5 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 4, 5, 0, 9, 6, 8, 1, 7, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            });

            Grid alternative1 = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 6, 0, 8, 0, 4, 2, 0, 3, 5 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 4, 5, 2, 9, 6, 8, 1, 7, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            });

            Grid alternative2 = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 6, 0, 8, 0, 4, 2, 0, 3, 5 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 4, 5, 3, 9, 6, 8, 1, 7, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            });

            Grid[] alternatives = grid.GetAlternatives().ToArray();

            Assert.AreEqual(2, alternatives.Length, "Number of alternatives");

            Assert.AreEqual(alternative1, alternatives[0], "First alternative");
            Assert.AreEqual(alternative2, alternatives[1], "Second alternative");
        }
开发者ID:aistrate,项目名称:SudokuSolver,代码行数:48,代码来源:GridTests.cs

示例3: GetAlternativesFromEmpty

        public void GetAlternativesFromEmpty()
        {
            Grid emptyGrid = new Grid(new[]
            {
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            });

            Grid alternative7 = new Grid(new[]
            {
                new[] { 7, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            });

            Grid[] alternatives = emptyGrid.GetAlternatives().ToArray();

            Assert.AreEqual(9, alternatives.Length, "Number of alternatives");

            Assert.AreEqual(alternative7, alternatives[6], "Alternative 7");
        }
开发者ID:aistrate,项目名称:SudokuSolver,代码行数:34,代码来源:GridTests.cs


注:本文中的Grid.GetAlternatives方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。