/* Recursively put a number into sudoku table*/ int put(int k){ int val,col,row; if(n_ans>1) return; row=k/9; // row number col=k%9; // column number /* If a number is originally placed in (rol,cow) grid ---> no number can be put there*/ if(sudoku_modified[row][col]!=EMPTY){ if(k<SIZE*SIZE-1) // If this is not the last put(k+1); // put a number to the next grid. else{ // Otherwise, a solution is found. ++n_ans; // Increment number of answers } } else{ for(val=0; val<SIZE; ++val){ /* If "val" can be put into (row,col) grid*/ if(column[col][val]==AVAILABLE && rows[row][val]==AVAILABLE && block[row][col/3][val/3]==AVAILABLE){ update(row,col,val); if(k<SIZE*SIZE-1){ put(k+1); } else{ ++n_ans; } remove_update(row,col,val); // remove "val" from (row,col) grid } } } return n_ans; }
static void remove_key (const gchar *key, gpointer closure, CryptUIKeyset *keyset) { /* This gets freed when removed from hashtable... */ gchar *k = g_strdup (key); if (!closure) closure = g_hash_table_lookup (keyset->priv->keys, k); g_hash_table_remove (keyset->priv->keys, k); remove_update (k, closure, keyset); g_free (k); }