# correct use of the command FindInstance

I have tried to solve this system for numbers that go from 1 to 10 non-repeated integers, this occurs to me

 FindInstance[
a + b == c + d + e + f == g + h == i + j == a + c + g + i ==
b + f + h + i && a > 0 && b > 0 && c > 0 && d > e > 0 && f > 0 &&
g > 0  && h > 0 && i > 0 && j > 0, {a, b, c, d, e, f, g, h, i, j}]


but I get nothing. One of the main aspects is how to indicate that the variables must be different (from 1 to 10 it is simple, but from 1 to 100 I cannot imagine) thanks for any help

Edit (Bill's suggestion) I have reformulated the problem and it works well, I just need to know which of all those results give me the maximum sum

 **Needs["Combinatorica"]; p =
Range; Do[{a, b, c, d, e, f, g, h, i, j} =
p = NextPermutation[p];
If[a + b +  c + d == b + e + f + h == g + h + i + j, Print[p]], {10!}]**

• ... b > 0 c > 0...? – ciao Jun 6 at 18:08
• b > 0 c > 0  makes the expression False. Presumably, you mean b > 0 && c > 0 . However, the result is then { } which indicates that there is no valid solution. – Bob Hanlon Jun 6 at 18:13
• Try Needs["Combinatorica"]; p=Range; Do[ {a,b,c,d,e,f,g,h,i,j}=p= NextPermutation[p]; If[a+b==c+d+e+f==g+h,Print[p]], {10!}] and ignore the caution about Combinatorica loading. After looking at that result insert the extra ==i+j condition and try it again. This avoids wondering whether FindInstance just didn't try hard enough and avoids 0<a<11&&0<b<11&&... (IF you have enough memory you can modify this to generate all the permutations first, but you will never be able to buy enough memory to hold 100! permutations while you can just wait longer for NextPermutation to find one) – Bill Jun 6 at 19:18
• @Bill , Thanks, see my edition please – BeTDa Jun 6 at 21:28
• @Bob Hanlon , thanks for your indication – BeTDa Jun 6 at 21:31

Clear["Global*"]

Needs["Combinatorica"];

p = Range;

sol = {};

Do[{a, b, c, d, e, f, g, h, i, j} = p = NextPermutation[p];
If[a + b + c + d == b + e + f + h == g + h + i + j,
sol = Append[sol, p]], {10!}]


The number of solutions is

Length@sol

(* 7200 *)


The greatest sum is

max = Max[Total /@ sol[[All, 1 ;; 4]]]

(* 24 *)


The solutions with the greatest sum are

sol2 = Select[sol, Total[#[[1 ;; 4]]] == max &];


The number of these solutions is

Length@sol2

(* 1152 *)


Verifying the solutions,

And @@ (
Total[#[[1 ;; 4]]] == Total[#[[{2, 5, 6, 8}]]] ==
Total[#[[7 ;; 10]]] == max & /@ sol2)

(* True *)

• thanks for your time – BeTDa Jun 8 at 20:36
• but as you can see the list of the numbers that meet this sum – BeTDa Jun 8 at 21:07