How many such Sudokus are there? Any reference to papers, books, articles or any insight into the problem will be greatly appreciated.
I've tried several search engines, scholarly and not, with no results. Maybe there is a terminology for them I am unaware of.
EDIT1 Title updated. No AP for any row or column.
EDIT2 Title updated. Consecutive AP.
The following C program produces 165K different solutions during a one minute run. This is a literal translation of the Perl code and some C style issues probably remain as I am not an expert C coder. Compiled with GCC 4.8.3.
#include <stdio.h> typedef struct { int row, col; } slot; typedef slot region[9]; typedef struct { region regions[27]; region *incidence[9][9][3]; } boardinf; typedef int boardvals[9][9]; void search(boardvals *bvptr, boardinf *binfptr, int sofar) { int row, col; if(sofar == 9*9){ for(row=0; row<9; row++){ for(col=0; col<9; col++){ if(col>0) printf(" "); printf("%d", (*bvptr)[row][col]); } printf("\n"); } printf("\n"); return; } col = sofar % 9; row = (sofar-col) / 9; int val; for(val = 1; val <= 9; val++){ (*bvptr)[row][col] = val; int admit = 1, regx; for(regx=0; regx<3; regx++){ region *reg = binfptr->incidence[row][col][regx]; int sx; for(sx=0; sx<9; sx++){ slot *s = (*reg)+sx; if(s->row != row || s->col != col){ if((*bvptr)[s->row][s->col] == val){ admit = 0; break; } } } if(!admit) break; } if(row>=2){ int ap[3] = { (*bvptr)[row-2][col], (*bvptr)[row-1][col], (*bvptr)[row][col] }; if(ap[2]-ap[1] == ap[1]-ap[0]){ admit = 0; } } if(col>=2){ int ap[3] = { (*bvptr)[row][col-2], (*bvptr)[row][col-1], (*bvptr)[row][col] }; if(ap[2]-ap[1] == ap[1]-ap[0]){ admit = 0; } } if(admit) search(bvptr, binfptr, sofar+1); (*bvptr)[row][col] = -1; } } int main(int argc, char **argv) { boardinf binf; int row, col, regx = 0; for(row=0; row<9; row++){ for(col=0; col<9; col++){ binf.regions[regx][col].row = row; binf.regions[regx][col].col = col; binf.incidence[row][col][0] = binf.regions+regx; } regx++; } for(col=0; col<9; col++){ for(row=0; row<9; row++){ binf.regions[regx][row].row = row; binf.regions[regx][row].col = col; binf.incidence[row][col][1] = binf.regions+regx; } regx++; } int x, y; for(y=0; y<3; y++){ for(x=0; x<3; x++){ int idx = 0; for(row=0; row<3; row++){ for(col=0; col<3; col++){ binf.regions[regx][idx].row = 3*y+row; binf.regions[regx][idx].col = 3*x+col; binf.incidence[3*y+row][3*x+col][2] = binf.regions+regx; idx++; } } regx++; } } boardvals bv; for(row=0; row<9; row++){ for(col=0; col<9; col++){ bv[row][col] = -1; } } search(&bv, &binf, 0); }Here are some of solutions that it computed.
The following three solutions are notable for swapping activity having reached the fourth row.