sudoku by yuyarin

l;char s[9][10];f(x,y){int c[60],i=0,z=s[y][x];if(z){for(memset(c,48/z,240);i<9;)c[s[i++][x]]=c[s[y][i]]=c[s[y/3*3+i/3][x/3*3+i%3]]=0;for(c[z]=i=49;i<58;i++)if(c[i])s[y][x]=i,f(x--%9,++x/9+y),s[y][x]=z;}else for(;i<10;)puts(s[i++]);}main(){for(;gets(s[l++]);)if(l/9)f(0,0),gets(s[l=0]);}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page