X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=matchsticks-search.git;a=blobdiff_plain;f=main.c;h=15b534bd3bc3c9eb0447b059e5bf013de4969b44;hp=e093311d63ea31e18909fdc7a7f71c6d409318bb;hb=3164b7155efcca47cfedccb778b5a7471629e2f4;hpb=59203f5a9c48db737e3b7b110139ab3a4242c081 diff --git a/main.c b/main.c index e093311..15b534b 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -12,7 +13,7 @@ typedef uint32_t AdjWord; #define PRADJ "08"PRIx32 -static int n, m; +static int n, m, maxhamweight; static AdjWord *adjmatrix; static AdjWord adjall; @@ -53,8 +54,12 @@ static void optimise(int doprint) { retry_with_print: #define PRINTF if (!doprint) ; else printf /* bodgy */ + PRINTF("%2d ", maxhamweight); + + bool had_max = 0; for (i=0, totalfrags=0; i maxhamweight) + goto again; + iterate_recurse(i+1, adjmatrix[i]); + + again: if (adjmatrix[i] == adjall) return; } } static void iterate(void) { - iterate_recurse(0, 1); + for (maxhamweight=1; maxhamweight<=m; maxhamweight++) { + double maxminsize = (double)m / maxhamweight; + if (maxminsize <= best) + continue; + + iterate_recurse(0, 1); + } } int main(int argc, char **argv) {