Exemple #1
0
bool sudokuSolver::fillColumn(int row,int column){
  if(row==9){
    return true;
  }
  else if(column==9){
    if(fillColumn(row+1,0))return true;
    else return false; 
  }

  else if(problem[row][column]==0){
    for(int i=1;i<=9;i++){
      ans[row][column]=i;
      for(int k=row;k<9;k++){
        if(k==row){
            for(int l=column+1;l<9;l++)
            ans[k][l]=problem[k][l];
        }
        else{
          for(int l=0;l<9;l++)
            ans[k][l]=problem[k][l];
        }
      }
     if(checkColumn(row,column) && checkRow(row,column) && checkBlock(row,column)) 
      if(fillColumn(row,column+1))return true;
    }
    return false;
  }
    else {if(fillColumn(row,column+1))return true;else return false;}
  }
Exemple #2
0
void moveMap( char** map )
{
  ++rounds;

  if (rounds == 80) {
    rounds = 0;
  }
  for (int x = rounds; x < 80; ++x) {
    fillColumn(map[x], x - rounds);
  }
  for (int x = 0; x < rounds; ++x) {
    fillColumn(map[x], 80 + x + 1);
  }
}
Exemple #3
0
sudokuSolver::status sudokuSolver::solve(){
  if(validateProblem()){
    if(fillColumn(0,0))return SOLVED;
    else return UNSOLVED;
  }
  else{
    return NOTVALID;
  }
}
void CSVVector::fillEmptyCells()
{
    //vul bij alle kolommen behalve de eerste twee alle lege velden
    for(int column = 0; column < columns(); column++)
    {
        if(isBooleanColumn(column))
            fillBooleanColumn(column);
        else
            fillColumn(column);
    }
}
/** see Kimmen's PhD-Thesis, pp42ff.
      I use equations 6.38 and 6.39 for calculating the pi
      using the logarithm of the beta-function, as Kimmen suggests.
      This method calculates the Xi and stores it in the profile. You have
      to call NormalizeColumn to get the correct estimated probabilites.
*/      
void ImplRegularizorDirichletFade::fillFrequencies( Frequency * frequencies, 
						    const Count * counts, 
						    const Position length,
						    const Residue width ) const 
{
	
	if (width != ALPHABET_SIZE)
		throw AlignlibException( "ImplRegularizorDirichletFade.cpp: profile width of profile has to be 20.")
		
    Position column;
    Count ntotal;

    int i,j;
    double Xi[width];
    
    // helper variables for the conversion of log to floating point
    TYPE_BETA_DIFFERENCES beta_differences;
 
    for (column = 0; column < length; column++) 
    {

	const Count * n = &counts[column * width];
	
	ntotal = 0;

	// get ntotal = number of observations
	for (i = 0; i < width; i++)
	    ntotal += n[i];
	
	// if the number of total observation is less than the fade cutoff, do the normal calculation. I have pasted and copied
	// it, maybe externalize it sometime later..

	if (ntotal < FADE_CUTOFF) 
	{
	    // use normal Dirichlet-Mixture
	    fillColumn( beta_differences, n. ntotal );
	}  
	else 
	{
	    // calculate raw frequencies:
		Frequency * column = frequencies[column * width];
	    for (i = 0; i < width; i++)
	    	frequencies[i] = (Frequency)(n[i] / ntotal);
	}
    }
}