2023W-EFFPROG

Magic Hexagon.
Log | Files | Refs | README

commit 202292d959901d24a16259ebf8727bd34c0b71d5
parent bd0e227c7e3059e4c71a9aa6ca824673a8d4d4a6
Author: EP2023 11912368 <ep11912368@g0.complang.tuwien.ac.at>
Date:   Sun,  7 Jan 2024 16:04:43 +0100

revert goto condition on the end

Diffstat:
Mmagichex/src/magichex.c | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/magichex/src/magichex.c b/magichex/src/magichex.c @@ -174,23 +174,27 @@ bool solve(HexagonEntry hexagon[]) if (occupation[hexagonEntry->lo-o] < number_hex_entries) return false; /* another variable has the same value */ occupation[hexagonEntry->lo-o] = i; /* occupy hexagonEntry->lo */ + //goto restart; } } - bool update_boundaries = false; + bool k = false; /* now propagate the alldifferent results to the bounds */ for (i=0; i<number_hex_entries; i++) { HexagonEntry *hexagonEntry = &hexagon[i]; if (hexagonEntry->lo < hexagonEntry->hi) { if (occupation[hexagonEntry->lo-o] < number_hex_entries) { hexagonEntry->lo++; - update_boundaries = true; + k = true; } if (occupation[hexagonEntry->hi-o] < number_hex_entries) { hexagonEntry->hi--; - update_boundaries = true; + k = true; } } } + if(k){ + goto restart; + } /* the < constraints; all other corners are smaller than the first one (eliminate rotational symmetry) */ for (i=1; i<sizeof(corners)/sizeof(corners[0]); i++) { @@ -212,17 +216,17 @@ bool solve(HexagonEntry hexagon[]) /* line */ f = sum(hexagon+r*i+max(0,i+1-n), min(i+n,r+n-i-1), 1, hexagon, hexagon+number_hex_entries); if (f==NOSOLUTION) return false; - if (f==CHANGED) update_boundaries = true; + if (f==CHANGED) k = true; /* column (diagonal down-left in the hexagon) */ f = sum(hexagon+i+max(0,i+1-n)*r, min(i+n,r+n-i-1), r, hexagon, hexagon+number_hex_entries); if (f==NOSOLUTION) return false; - if (f==CHANGED) update_boundaries = true; + if (f==CHANGED) k = true; /* diagonal (down-right) */ f = sum(hexagon-n+1+i+max(0,n-i-1)*(r+1), min(i+n,r+n-i-1), r+1, hexagon, hexagon+number_hex_entries); if (f==NOSOLUTION) return false; - if (f==CHANGED) update_boundaries = true; + if (f==CHANGED) k = true; } - if(update_boundaries){ + if(k){ goto restart; } return true; // all done