#include <stdlib.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include "../libcnf/libcnf.h"
Go to the source code of this file.
Defines | |
#define | NONE 100 |
Functions | |
void | oneValuePerCell (unsigned int i, unsigned int j, Formula *form) |
Adds the clauses encoding the fact that each cell must have one and only one value to the Formula form. | |
void | oneValuePerLine (unsigned int i, Formula *form) |
Adds the clauses corresponding to the uniqueness of each number in a line. | |
void | oneValuePerColumn (unsigned int j, Formula *form) |
Adds the clauses corresponding to the uniqueness of each number in a column. | |
void | oneValuePerSquare (unsigned int i, unsigned int j, Formula *form) |
Adds the clauses corresponding to the fact that each number appears only once in each square. | |
void | grid2restriction (std::vector< std::vector< int > > grid, Formula *form, VariableSet *vars) |
Adds the clauses corresponding to an assignment of the literals known for the sudoku grid. | |
std::vector< std::vector< int > > | parseGrid (std::istream *input) |
Reads a sudoku grid from the input stream and stores it in a std::vector of std::vector of int. | |
int | main (int argc, char **argv) |
#define NONE 100 |
The value to put in a grid when the value of a cell is not known. It ought to be different from 0..9.
Definition at line 17 of file sudoku2formula.cpp.
void grid2restriction | ( | std::vector< std::vector< int > > | grid, |
Formula * | form, | ||
VariableSet * | vars | ||
) |
Adds the clauses corresponding to an assignment of the literals known for the sudoku grid.
For each cell of grid, if it is known, adds a one-literal clause to the formula form for each literal corresponding to it.
Definition at line 126 of file sudoku2formula.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 183 of file sudoku2formula.cpp.
void oneValuePerCell | ( | unsigned int | i, |
unsigned int | j, | ||
Formula * | form | ||
) |
Adds the clauses encoding the fact that each cell must have one and only one value to the Formula form.
First, we add for k<k' and then, second, we add
Definition at line 28 of file sudoku2formula.cpp.
void oneValuePerColumn | ( | unsigned int | j, |
Formula * | form | ||
) |
Adds the clauses corresponding to the uniqueness of each number in a column.
We add for i<i', for all k to the Formula form.
Definition at line 79 of file sudoku2formula.cpp.
void oneValuePerLine | ( | unsigned int | i, |
Formula * | form | ||
) |
Adds the clauses corresponding to the uniqueness of each number in a line.
We add for j<j', for all k in the Formula form.
Definition at line 57 of file sudoku2formula.cpp.
void oneValuePerSquare | ( | unsigned int | i, |
unsigned int | j, | ||
Formula * | form | ||
) |
Adds the clauses corresponding to the fact that each number appears only once in each square.
Adds the clauses for all (i,j) and (i',j') in the square and for all k in [0,8].
Definition at line 102 of file sudoku2formula.cpp.
std::vector< std::vector<int> > parseGrid | ( | std::istream * | input | ) |
Reads a sudoku grid from the input stream and stores it in a std::vector of std::vector of int.
Definition at line 149 of file sudoku2formula.cpp.