Beispiel #1
0
def board_from_request(req):
    out = build_blank_board()
    for row in range(9):
        for col in range(9):
            key = ("cell%d_%d" % (row, col))

            val = req.get(key)
            if val:
                try:
                    val = int(val)
                    out[row][col] = val
                except ValueError, e:
                    pass
Beispiel #2
0
def board_from_request(req):
  out = build_blank_board()
  for row in range(9):
    for col in range(9):
      key = ("cell%d_%d" % (row, col))

      val = req.get(key)
      if val:
        try:
          val = int(val)
          out[row][col] = val
        except ValueError, e:
          pass
Beispiel #3
0
from unittest import TestCase

from sudokudlx.sparsematrix import SparseMatrix
from sudokudlx.sudoku import SudokuPuzzle
from sudokudlx.fileutil import build_sudoku
from sudokudlx import sudoku

from copy import deepcopy

blank = sudoku.build_blank_board()


class SudokuTests(TestCase):
    def testRowColToBox(self):
        r, c = 0, 0
        box = sudoku.row_col_to_box(r, c)
        assert box == 0

        r, c = 8, 8
        box = sudoku.row_col_to_box(r, c)
        assert box == 8

        r, c = 4, 4
        box = sudoku.row_col_to_box(r, c)
        assert box == 4

    def testDlxRow(self):
        dlxrow = sudoku.dlx_row(0, 0, 1)
        assert len(dlxrow) == 324
        assert sum(dlxrow) == 4
Beispiel #4
0
from unittest import TestCase

from sudokudlx.sparsematrix import SparseMatrix
from sudokudlx.sudoku import SudokuPuzzle
from sudokudlx.fileutil import build_sudoku
from sudokudlx import sudoku

from copy import deepcopy

blank = sudoku.build_blank_board()


class SudokuTests(TestCase):
    def testRowColToBox(self):
        r, c = 0, 0
        box = sudoku.row_col_to_box(r, c)
        assert box == 0

        r, c = 8, 8
        box = sudoku.row_col_to_box(r, c)
        assert box == 8

        r, c = 4, 4
        box = sudoku.row_col_to_box(r, c)
        assert box == 4

    def testDlxRow(self):
        dlxrow = sudoku.dlx_row(0, 0, 1)
        assert len(dlxrow) == 324
        assert sum(dlxrow) == 4