Accueil > Forum > > > > solveur kakuro
solveur kakuro
lundi 30 juillet 2007 à 12:48:54 |
solveur kakuro

kspeciall
|
Bonjour à tous, Je dois faire un solveur de kakuro en java dans le cadre d'un projet complémentaire et je galère un peu. Je voulais savoir si quelqu'un à déjà réaliser ce solveur et si oui si vous pouviez me donner les classes de bases. Je sais que je devrais le faire tout seul mais je suis actuellement en stage à l'étranger et je manque de temps pour faire le solveur que je dois rendre dans un mois. Je vous remercie d'avance
|
|
mardi 31 juillet 2007 à 11:02:44 |
Re : solveur kakuro
|
vendredi 3 août 2007 à 11:36:59 |
Re : solveur kakuro

coucou747
|
Salut http://www.cppfrance.com/codes/SOLVEUR-KAKORUS-CPLUSPLUS_41116.aspx une recherche sur exalead vous aurait peut-etre evite de poser cette questionIn a dream, I saw me, drop dead... U were there, U cried... It was just a dream, if I die, U won't cry, maybe, U'll be happy
|
|
jeudi 9 août 2007 à 11:07:25 |
Lien vers forum officiel SUN

loloof64
|
Bonjour,
voici un lien d'une page en anglais qui pourrait t'aider, si tu veux programmer ce solveur en JAVA. C'est grâce à cette page que j'ai réussi .
http://forum.java.sun.com/thread.jspa?threadID=766548&tstart=240
|
|
mardi 26 mai 2009 à 15:33:56 |
Re : solveur kakuro

loloof64
|
Désolé de poster ce message en retard, mais comme le code d'origine comportait quelques erreurs qui le rendaient inexploitables (son auteur précise qu'il ne l'avait pas testé), j'ai pensé qu'il était utile de proposer ici des modifications : d'autant plus que j'ai eu un peu de mal à corriger les erreurs .
--------------------------------------------------------------------------------------------------------------------
/** * Source originale recuperee le 23/05/2009 sur http://forums.sun.com/thread.jspa?threadID=766548&tstart=240 * (forum officiel de Sun) */
// recursive backtrack for Kakuro class Cell{ // you make one of these for each cell that gets a number filled into it // every cell participates in both a row sum and a col sum static Cell[] all; // all Created cells - you figure out how to build this int val; // holds the solution value Sum row; Sum col; static class Sum{ // you build one of these for each row sum and one for each col sum // you figure out how to initialize this but note: two cells that share a row // MUST actually have the same row Sum embedded in them. the backtracking // assumes that shared data is in fact shared and not copied. int total; // total needed in remaining cells int digitsUsed = 0; // bitsset that keeps track of all digits already used in this row,or col int cellsLeft; // count of slots in this row or col (updated by place) /* * Default constructor * Be Carrefull ! Field cellsLeft must be initialised before * using valid(int, int) methods * => this method is based on cellsLeft field value . */ Sum(){ } /* * Usefull constructor * Should be preferred to the default constructor . */ Sum(int r, int n){ total = r; cellsLeft = n; } //For methods valid, add, and remove : 'digit' must be 2<<i boolean valid(int i, int digit){ //true if 'i' is not yet registered in Sum if((digitsUsed & digit) != 0) return false; // digit was already in use if((cellsLeft > 1 && total > i) || (cellsLeft == 1 && total == i)) return true; return false; } void add(int i, int digit){ // only called for valid entries total -= i; digitsUsed |= digit; // set bit indicating digit is used cellsLeft--; } void remove(int i, int digit){ // called when backing out a result total += i; digitsUsed &= ~digit; // unset bit indicating digit is used cellsLeft++; } } static final int DONE = 1; static final int BACKTRACK = 2; static void solve(){ place(0); System.out.println("That's all, folks!"); } static int place(int cellIndex){ // tries to place value in this cell if(cellIndex == Cell.all.length) {return Cell.DONE;} Cell c = Cell.all[cellIndex]; int digit = 1; for(int i = 1; i<10; i++){ if (c.row.valid(i,digit) && c.col.valid(i,digit) ){ c.val = i; //set the value in the cell c.row.add(i,digit); c.col.add(i,digit); if(Cell.DONE == place(cellIndex+1)) return Cell.DONE; c.row.remove(i, digit); // back out because last place failed c.col.remove(i, digit); digit *= 2; // advance digit bit } // else digit not legit so don't place, just try next number } // end of digits and not yet done so...Backtrack return Cell.BACKTRACK; } }
---------------------------------------------------------------------------------------------------------------
|
|
Cette discussion est classée dans : solveur, kakuro
Répondre à ce message
Livres en rapport
|
Derniers Blogs
XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio [WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz
Forum
RE : URL ET JAVARE : URL ET JAVA par Pylouq
Cliquez pour lire la suite par Pylouq
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|