Alvaro Martins Posted February 19, 2006 at 03:52 PM Report Share #14626 Posted February 19, 2006 at 03:52 PM Hi there, Parabens pelo sistema e pelo projecto 😕 Tenho uma questao para os programmers... Terminei um programa para gerar puzzles de sudoku... de diversas dimensões... e gostaria de falar com alguem que tenha feito algum semelhante.. pois tou com um problema ao gerar o puzzle mascarado.. nao tem simetria que deve ter. a soluçao que uso irei mostrar se alguem estiver interessado. Já vi um ou outro na net, mas nenhum tem a soluçao que pretendo 😉 Cumps, Alvaro Link to comment Share on other sites More sharing options...
saramgsilva Posted February 19, 2006 at 03:55 PM Report Share #14627 Posted February 19, 2006 at 03:55 PM Hi there, Parabens pelo sistema e pelo projecto 😉 Tenho uma questao para os programmers... Terminei um programa para gerar puzzles de sudoku... de diversas dimensões... e gostaria de falar com alguem que tenha feito algum semelhante.. pois tou com um problema ao gerar o puzzle mascarado.. nao tem simetria que deve ter. a soluçao que uso irei mostrar se alguem estiver interessado. Já vi um ou outro na net, mas nenhum tem a soluçao que pretendo 🙂 Cumps, Alvaro boas, na revista que foi lançada, Programar fala la de 1 site com codigo fonte do sundoku em Python, tv encontres la a tua resposta, ou nao...mas da 1 vista de olhos!! 😕 www.saramgsilva.com As minhas apps no WP7 Marketplace Youtube : Galinho - Windows Phone 7.5 Link to comment Share on other sites More sharing options...
Marino Posted March 3, 2006 at 02:16 PM Report Share #16536 Posted March 3, 2006 at 02:16 PM Deixo aqui um programa em C, para o sudoku, nao sei ao certo o que faz, nem sei se funciona, pois não o testei #include <stdio.h> # define N 3 # define N2 N*N # define N4 N2*N2 int A[N2+1][N2+1],Rows[4*N4+1],Cols[N4*N2+1],Row[4*N4+1][N2+1]; int Col[N4*N2+1][5],Ur[N4*N2+1],Uc[4*N4+1],C[N4+1],I[N4+1],Node[N4+1]; int i,j,k,r,c,d,n=N4*N2,m=4*N4,x,y,s; int max,min,clues,match; char l[65]="-123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#*~"; FILE *file; int main(int argc,char*argv[]) { if(argc<2) { m5: printf("\nusage:suexco file\n\n"); printf(" prints the number of solutions of the sudoku-puzzle in file\n"); printf(" empty cells are -.* or 0 , other nondigit-characters are"); printf(" ignored\n");exit(1); } if((file=fopen(argv[1],"rb"))==NULL) { fclose(file); printf("\nfile-error\n\n"); goto m5; } i=0; for (x=1;x<=N2;x++) { for (y=1;y<=N2;y++) { m1: if (feof(file)) { printf("\nonly %i sudoku-entries found in file %s\n",i,argv[1]); goto m5; } c=fgetc(file); j=0; if (c=='-' || c=='.'|| c=='0' || c=='*') goto m7; while (l[j] != c && j<=N2) j++; if(j>N2) goto m1; m7: A[x][y]=j; i++; } } r=0; for (x=1;x<=N2;x++) { for (y=1;y<=N2;y++) { for (s=1;s<=N2;s++) { r++; Cols[r]=4; Col[r][1]=x*N2-N2+y; Col[r][2]=(N*((x-1)/N)+(y-1)/N)*N2+s+N4; Col[r][3]=x*N2-N2+s+N4*2; Col[r][4]=y*N2-N2+s+N4*3; } } } for (c=1;c<=m;c++) Rows[c]=0; for (r=1;r<=n;r++) { for(c=1;c<=Cols[r];c++) { x=Col[r][c]; Rows[x]++; Row[x][Rows[x]]=r; } } for (i=0; i<=n; i++) Ur[i]=0; for (i=0; i<=m; i++) Uc[i]=0; for (x=1;x<=N2;x++) { for (y=1;y<=N2;y++) { if(A[x][y]) { clues++; r=x*N4-N4+y*N2-N2+A[x][y]; for(j=1;j<=Cols[r]; j++) { d=Col[r][j]; Uc[d]++; for (k=1;k<=Rows[d];k++) { Ur[Row[d][k]]++; } } } } } i=0; m2: i++; I[i]=0; min=n+1; for (c=1;c<=m;c++) { if (Uc[c]==0) { match=0; for (r=1;r<=Rows[c];r++) { if (Ur[Row[c][r]]==0) match++; } if(match<min) { min=match; C[i]=c; } } } if (min==0 || min>n) goto m4; m3: c=C[i]; I[i]++; if (I[i] > Rows[c]) goto m4; r=Row[c][i[i]]; if (Ur[r]) goto m3; //x=(r-1)/N4+1;y=((r-1)%N4)/N2+1;s=(r-1)%(N2)+1;A[x][y]=s;if(clues+i==N4)output; for (j=1;j<=Cols[r];j++) { d=Col[r][j]; Uc[d]++; for (k=1;k<=Rows[d];k++) Ur[Row[d][k]]++; } Node[i]++; goto m2; m4: i--; c=C[i]; r=Row[c][i[i]]; for (j=1;j<=Cols[r];j++) { d=Col[r][j]; Uc[d]--; for (k=1;k<=Rows[d];k++) { Ur[Row[d][k]]--; } } if(i>0) goto m3; printf("\n%i solutions\n",Node[N4-clues]); } Fonte : http://www.setbb.com/sudoku/viewtopic.php?t=119&mforum=sudoku Link to comment Share on other sites More sharing options...
pedrotuga Posted March 22, 2006 at 05:51 PM Report Share #19092 Posted March 22, 2006 at 05:51 PM Lá está uma coisa que eu a seu tempo vou fazer... um programa para resolver sudokus Mas agora n há tempo p isso. Nas ferias grandse talvez Link to comment Share on other sites More sharing options...
Threshold Posted April 5, 2006 at 11:59 PM Report Share #21084 Posted April 5, 2006 at 11:59 PM Boas, Uma coisa é certa o processador foi feito para processar, mas esses fors até metem medo 😁. Eu acho que fiquei fan mas pronto tenho de recomendar, dá uma vista de olhos em prolog e repara que a matemática nao é só numeros 🙂 Apenas um conselho de optimização 🙂 Fica bem, boas sorte Link to comment Share on other sites More sharing options...
JoBlack Posted April 9, 2006 at 08:49 PM Report Share #21520 Posted April 9, 2006 at 08:49 PM Olá, cá vai mais um link para uma possível solução... http://www.techfinesse.com/game/sudoku_solver.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now