update nb_solution
This commit is contained in:
1 parent
696e71f7fb
commit
1ef818953c
1 file changed
+6
-3
+6
-3
@@ -124,7 +124,7 @@ uint game_nb_solutions_aux(game g, game* games) {
|
|||||||
if (game_solve(g) == false) {
|
if (game_solve(g) == false) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
games = (game*)calloc(sizeof(game));
|
games = (game*)malloc(sizeof(game));
|
||||||
games[0] = game_copy(g);
|
games[0] = game_copy(g);
|
||||||
uint** tab = (uint**)malloc(sizeof(uint*) * (g->height * g->width));
|
uint** tab = (uint**)malloc(sizeof(uint*) * (g->height * g->width));
|
||||||
for (uint r = 0; r < (g->height * g->width); r++) {
|
for (uint r = 0; r < (g->height * g->width); r++) {
|
||||||
@@ -144,6 +144,8 @@ uint game_nb_solutions_aux(game g, game* games) {
|
|||||||
game game_test = game_copy(game_save);
|
game game_test = game_copy(game_save);
|
||||||
res = res + game_nb_solutions_aux(game_test, &games[1]);
|
res = res + game_nb_solutions_aux(game_test, &games[1]);
|
||||||
}
|
}
|
||||||
|
free(games);
|
||||||
|
free(tab);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,12 +156,13 @@ uint game_nb_solutions(cgame g) {
|
|||||||
uint res = nb;
|
uint res = nb;
|
||||||
for (uint n = 0; n < nb; n++) {
|
for (uint n = 0; n < nb; n++) {
|
||||||
for (uint i = n; i < nb; i++) {
|
for (uint i = n; i < nb; i++) {
|
||||||
game g1 = g_tmp[n];
|
game g1 = games[n];
|
||||||
game g2 = g_tmp[i];
|
game g2 = games[i];
|
||||||
if (game_equal(g1, g2)) {
|
if (game_equal(g1, g2)) {
|
||||||
res--;
|
res--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(games);
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user