Esempio n. 1
0
    def test_preprocess_vertical(self):
        preprocessor = LineBlockPreprocessor()

        data = '29X7X5X481XX6892738X7X249X5XXX2X1XXXXX24X' \
               '68XX6X98X342X9XX5X2XX44XXXX8X92321947586'

        layer = Layer(data, SOLUTION)
        self.assertEquals(layer._candidates[28], set(['3', '4', '5',
                                                      '7', '8']))
        self.assertEquals(layer._candidates[37], set(['1', '3', '5', '7']))
        self.assertEquals(layer._candidates[46], set(['1', '5', '7']))
        self.assertEquals(layer._candidates[55], set(['6', '7', '8']))
        self.assertEquals(layer._candidates[64], set(['5', '6', '7']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[28], set(['3', '4', '5', '8']))
        self.assertEquals(layer._candidates[37], set(['1', '3', '5']))
        self.assertEquals(layer._candidates[46], set(['1', '5']))
        self.assertEquals(layer._candidates[55], set(['6', '7', '8']))
        self.assertEquals(layer._candidates[64], set(['5', '6', '7']))
Esempio n. 2
0
    def test_preprocess_failing(self):
        preprocessor = LineBlockPreprocessor()

        data = '3XXX3X81XX28X1X7X41X78XX2XX2X917X3XXX56XX' \
               'X1X7731X8X4X2XXXX4192XX1X96X5XXXXXX5X6X1'

        layer = Layer(data, SOLUTION)
        self.assertEquals(layer._candidates[16], set(['3', '5', '6', '9']))
        self.assertEquals(layer._candidates[25], set(['3', '5', '6', '9']))
        self.assertEquals(layer._candidates[34], set(['5', '6', '8']))
        self.assertEquals(layer._candidates[43], set(['8', '9']))
        self.assertEquals(layer._candidates[52], set(['5', '6', '9']))
        self.assertEquals(layer._candidates[70], set(['3', '4', '7', '8']))
        self.assertEquals(layer._candidates[79], set(['3', '4', '7', '8']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[16], set(['3', '5', '6']))
        self.assertEquals(layer._candidates[25], set(['3', '5', '6']))
        self.assertEquals(layer._candidates[34], set(['5', '6', '8']))
        self.assertEquals(layer._candidates[43], set(['8', '9']))
        self.assertEquals(layer._candidates[52], set(['5', '6', '9']))
        self.assertEquals(layer._candidates[70], set(['3', '4', '7', '8']))
        self.assertEquals(layer._candidates[79], set(['3', '4', '7', '8']))
Esempio n. 3
0
    def test_preprocess_horizontal(self):
        preprocessor = LineBlockPreprocessor()

        data = '29X7X5X481XX6892738X7X249X5XXX2X1XXXXX24X' \
               '68XXXX98X342X9XX5X2XX44XXXX8X92321947586'

        layer = Layer(data, SOLUTION)
        self.assertEquals(layer._candidates[27], set(['5', '6', '7']))
        self.assertEquals(layer._candidates[28], set(['3', '4', '5',
                                                      '6', '7', '8']))
        self.assertEquals(layer._candidates[29], set(['3', '4', '5',
                                                      '6', '8']))
        self.assertEquals(layer._candidates[33], set(['3', '6', '7']))
        self.assertEquals(layer._candidates[34], set(['3', '5', '6']))
        self.assertEquals(layer._candidates[35], set(['7', '9']))

        layer = preprocessor.preprocess(layer)
        self.assertEquals(layer._candidates[27], set(['5', '7']))
        self.assertEquals(layer._candidates[28], set(['3', '4', '5',
                                                      '7', '8']))
        self.assertEquals(layer._candidates[29], set(['3', '4', '5', '8']))
        self.assertEquals(layer._candidates[33], set(['3', '6', '7']))
        self.assertEquals(layer._candidates[34], set(['3', '5', '6']))
        self.assertEquals(layer._candidates[35], set(['7', '9']))