示例#1
0
    def test_preprocess_horizontal_for_coverage(self):
        preprocessor = BlockBlockPreprocessor()

        data = '7X94X85X64XXXX69X7X6X79X4839X46XX87587XX4' \
               'X692625987341396871254XXX264739247359168'

        layer = Layer(data, SOLUTION)
        layer = LineBlockPreprocessor().preprocess(layer)
        self.assertEquals(layer._candidates[1], set(['1', '3']))
        self.assertEquals(layer._candidates[10], set(['1', '3', '5', '8']))
        self.assertEquals(layer._candidates[11], set(['1', '2', '3', '8']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[1], set(['3']))
        self.assertEquals(layer._candidates[10], set(['3', '5', '8']))
        self.assertEquals(layer._candidates[11], set(['2', '3', '8']))

        data = data[::-1]

        layer = Layer(data, SOLUTION)
        layer = LineBlockPreprocessor().preprocess(layer)
        self.assertEquals(layer._candidates[79], set(['1', '3']))
        self.assertEquals(layer._candidates[70], set(['1', '3', '5', '8']))
        self.assertEquals(layer._candidates[69], set(['1', '2', '3', '8']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[79], set(['3']))
        self.assertEquals(layer._candidates[70], set(['3', '5', '8']))
        self.assertEquals(layer._candidates[69], set(['2', '3', '8']))
示例#2
0
    def test_preprocess_vertical(self):
        preprocessor = BlockBlockPreprocessor()

        data = '29X7X5X481XX6892738X7X249X5XXX2X1XXXXX24X' \
               '68XX6X98X342X9XX5X2XX44XXXX8X92321947586'

        layer = Layer(data, SOLUTION)
        layer = LineBlockPreprocessor().preprocess(layer)
        layer = LineBlockPreprocessor().preprocess(layer)
        self.assertEquals(layer._candidates[28], set(['3', '4', '5', '8']))
        self.assertEquals(layer._candidates[29], set(['3', '4', '5', '8']))
        self.assertEquals(layer._candidates[37], set(['1', '3', '5']))
        self.assertEquals(layer._candidates[46], set(['1', '5']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[28], set(['3', '4', '8']))
        self.assertEquals(layer._candidates[29], set(['3', '4', '8']))
        self.assertEquals(layer._candidates[37], set(['1', '3']))
        self.assertEquals(layer._candidates[46], set(['1']))
示例#3
0
    def test_preprocess_horizontal(self):
        preprocessor = BlockBlockPreprocessor()

        data = 'XX5X7X89XX198X2XX5487XXXXX2XX3XXX5X8954X8' \
               'XX26XX8XXX9XX541798263732465189896X2X457'

        layer = Layer(data, SOLUTION)
        self.assertEquals(layer._candidates[30], set(['1', '2', '6', '9']))
        self.assertEquals(layer._candidates[31], set(['1', '4']))
        self.assertEquals(layer._candidates[32], set(['1', '4', '6',
                                                      '7', '9']))
        self.assertEquals(layer._candidates[48], set(['1', '2', '3',
                                                      '5', '6']))
        self.assertEquals(layer._candidates[49], set(['1', '3', '4', '5']))
        self.assertEquals(layer._candidates[50], set(['1', '3', '4',
                                                      '6', '7']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[30], set(['2', '6', '9']))
        self.assertEquals(layer._candidates[31], set(['4']))
        self.assertEquals(layer._candidates[32], set(['4', '6', '7', '9']))
        self.assertEquals(layer._candidates[48], set(['2', '3', '5', '6']))
        self.assertEquals(layer._candidates[49], set(['3', '4', '5']))
        self.assertEquals(layer._candidates[50], set(['3', '4', '6', '7']))