Skip to content

Instantly share code, notes, and snippets.

@Sigmanificient
Created June 4, 2024 23:25
Show Gist options
  • Save Sigmanificient/6c3d519935838c960e0e5aade7a47263 to your computer and use it in GitHub Desktop.
Save Sigmanificient/6c3d519935838c960e0e5aade7a47263 to your computer and use it in GitHub Desktop.
#define I(n,m)J(n,m,0)
#define J(n,m,e)for(n=m;--n;o|=e)
#define K(x)int x[9]={0}
o,i,j,x,y;is_sudoku_valid(int s[9][9]){I(i,9)J(j,9,s[i][j]<0||s[i][j]>9);I(y,9){K(c);J(j,9,c[s[y][j]-1]++);K(d);J(i,9,d[s[y][i]-1]++);};I(x,3)I(y,3){K(c);I(i,3)J(j,3,c[s[3*y+i][3*x+j]-1]++);};return !o;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment