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


Python Sudoku.find_hidden_longer方法代码示例

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


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

示例1: Test

# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import find_hidden_longer [as 别名]
class Test(unittest.TestCase):

    def setUp(self):
        str_sudoku = """003020600
                        900305001
                        001806400
                        008102900
                        700000008
                        006708200
                        002609500
                        800203009
                        005010300"""

        int_sudoku = []
        for line in str_sudoku.split("\n"):
            int_sudoku.append([int(i) for i in list(line.strip())])
        self.s = Sudoku(int_sudoku)

    def testHiddenLongerInRow_1(self):
        # 2 IS HIDDEN LONGER
        c1 = CellData(1)
        c2 = CellData(4)
        c3 = CellData(0)#
        c3.suggests = [3, 5, 8]
        c4 = CellData(6)
        c5 = CellData(7)
        c6 = CellData(0)#
        c6.suggests = [5, ]
        c7 = CellData(0)#
        c7.suggests = [2, 3, 8]
        c8 = CellData(9)
        c9 = CellData(0)#
        c9.suggests = [3, 8]
        cells = [c1, c2, c3, c4, c5, c6, c7, c8, c9]
        result = self.s.find_hidden_longer(cells)
        for cell in cells:
            print cell.suggests
        print result

    def testHiddenLongerInRow_2(self):
        # 4 IS HIDDEN LONGER
        c1 = CellData(0)
        c1.suggests = [7, ]
        c2 = CellData(0)
        c2.suggests = [3, 5]
        c3 = CellData(1)
        c4 = CellData(9)
        c5 = CellData(0)
        c5.suggests = [4, 5, 6]
        c6 = CellData(0)
        c6.suggests = [5, 6]
        c7 = CellData(2)
        c8 = CellData(8)
        c9 = CellData(0)
        c9.suggests = [3, 5, 7]
        cells = [c1, c2, c3, c4, c5, c6, c7, c8, c9]
        result = self.s.find_hidden_longer(cells)
        print result


    def testHiddenLongerInRow_3_Two_hidden_longer(self):
        # 4 IS HIDDEN LONGER
        c1 = CellData(0)
        c1.suggests = [7, 2]
        c2 = CellData(0)
        c2.suggests = [3, 5]
        c3 = CellData(1)
        c4 = CellData(9)
        c5 = CellData(0)
        c5.suggests = [4, 5, 6]
        c6 = CellData(0)
        c6.suggests = [5, 6]
        c7 = CellData(2)
        c8 = CellData(8)
        c9 = CellData(0)
        c9.suggests = [3, 5, 7]
        cells = [c1, c2, c3, c4, c5, c6, c7, c8, c9]
        result = self.s.find_hidden_longer(cells)
        print result

    def testHiddenLongerInRow_2_NOT_FOUND(self):
        c1 = CellData(0)
        c1.suggests = [7, 4]  # 4 TEST VALUE
        c2 = CellData(0)
        c2.suggests = [3, 5]
        c3 = CellData(1)
        c4 = CellData(9)
        c5 = CellData(0)
        c5.suggests = [4, 5, 6]
        c6 = CellData(0)
        c6.suggests = [5, 6]
        c7 = CellData(2)
        c8 = CellData(8)
        c9 = CellData(0)
        c9.suggests = [3, 5, 7]
        cells = [c1, c2, c3, c4, c5, c6, c7, c8, c9]
        result = self.s.find_hidden_longer(cells)
        print result

    def testSolveMethod(self):
#.........这里部分代码省略.........
开发者ID:sdenisen,项目名称:python,代码行数:103,代码来源:unittests.py


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