Originally posted by TimberWolf
View Post

1 2 3 4
2
5 4 3 2
4
1 2 3
// calculate, do NOT cycle the final row
s = Box[4][0] = 15 - Box[3][0] - Box[2][0] - Box[1][0] - Box[0][0];
if (s < 1 || s > 5) continue;
s = Box[4][1] = 15 - Box[3][1] - Box[2][1] - Box[1][1] - Box[0][1];
if (s < 1 || s > 5) continue;
s = Box[4][2] = 15 - Box[3][2] - Box[2][2] - Box[1][2] - Box[0][2];
if (s < 1 || s > 5) continue;
s = Box[4][3] = 15 - Box[3][3] - Box[2][3] - Box[1][3] - Box[0][3];
if (s < 1 || s > 5) continue;
s = Box[4][4] = 15 - Box[3][4] - Box[2][4] - Box[1][4] - Box[0][4];
if (s < 1 || s > 5) continue;
boxsolution(Box); // test full grid
// calculate, do NOT cycle the final row
s = Box[4][0] = 15 - Box[3][0] - Box[2][0] - Box[1][0] - Box[0][0];
if (s < 1 || s > 5) continue;
s = Box[4][1] = 15 - Box[3][1] - Box[2][1] - Box[1][1] - Box[0][1];
if (s < 1 || s > 5) continue;
s = Box[4][2] = 15 - Box[3][2] - Box[2][2] - Box[1][2] - Box[0][2];
if (s < 1 || s > 5) continue;
s = Box[4][3] = 15 - Box[3][3] - Box[2][3] - Box[1][3] - Box[0][3];
if (s < 1 || s > 5) continue;
s = Box[4][4] = 15 - Box[3][4] - Box[2][4] - Box[1][4] - Box[0][4];
if (s < 1 || s > 5) continue;
boxsolution(Box); // test full grid


Comment