2023W-EFFPROG

Magic Hexagon.
Log | Files | Refs | README

commit f09e7abb9db914613d52914f904b646d25ca3c15
parent b6cf0aadf2b778630b37e716fe6096b50544da06
Author: Luka Kalezic <kaleza98@gmail.com>
Date:   Thu, 21 Dec 2023 18:31:41 +0100

Reduce goto jumps

Diffstat:
Mmagichex/src/magichex.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/magichex/src/magichex.c b/magichex/src/magichex.c @@ -170,20 +170,24 @@ bool solve(unsigned long n, long d, HexagonEntry hexagon[]) //goto restart; } } + bool k = false; /* now propagate the alldifferent results to the bounds */ for (i=0; i<r*r; i++) { HexagonEntry *hexagonEntry = &hexagon[i]; if (hexagonEntry->lo < hexagonEntry->hi) { if (occupation[hexagonEntry->lo-o] < r*r) { hexagonEntry->lo++; - goto restart; + k = true; } if (occupation[hexagonEntry->hi-o] < r*r) { hexagonEntry->hi--; - goto restart; + 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++) {