Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Clear[a, b, c, d, e, f, g, h];
- sol = {a, b, c, d, e, f, g, h} /. Solve[{
- (*Max[{a,b,c,d,e,f,g,h}]\[Equal]14,*)
- (*Min[{a,b,c,d,e,f,g,h}]\[Equal]1,*)
- Total[{a, b, c, d, e, f, g, h} -
- Sort[{a, b, c, d, e, f, g, h}]] == 0,
- Abs[Total[{a, b, c, d}] - Total[{e, f, g, h}]] ==
- 16, (*48 value row5 has 192 for this,
- 480 value row6 has 3840 for this,
- 5760 value row7 has 552960 for this, 16,16*12,16*12*20,
- 16*12*20*12^2*)
- (*h\[Equal]4,(*last value hard coded constraint*)*)
- (*g\[Equal]13,(*penultimate value hard coded constraint,
- since have formula for the penultimate value*)*)
- g > 0,
- (*
- a+e+c+g\[Equal]32,(*32+28=
- 60 is from the sequence with row length 1,3,15,45,45,405*)
- b+f+d+h\[Equal]28,
- *)
- (*
- (a+e+c+g)-(b+f+d+h)\[Equal]4,
- *)
- a + h == 15,
- b + g == 15,
- c + f == 15,
- d + e == 15,
- a + b + c + d + e + f + g + h == 60,
- a - b == g - h,
- b - c == f - g,
- c - d == e - f,
- d - e == b - c,(*additional middle value formula,
- not sure if valid for larger rows*)
- d - e == f - g,(*additional middle value formula,
- not sure if valid for larger rows*)
- a - b + b - c + c - d + d - e + e - f + f - g + g - h == 7,
- b - a + c - b + d - c + e - d + f - e + g - f + h -
- g == -7,(*some of these constraints are redundant but ok to \
- leave them in*)
- (*
- Mod[c,2]>0,
- Mod[d,2]\[Equal]0,
- *)
- Total[Abs[{a - b, b - c, c - d, d - e, e - f, f - g, g - h}]] == 35
- },
- {a, b, c, d, e, f, g, h}, Integers]
- sol2 = Select[
- sol, ({a, b, c, d, e, f, g, h} = #;
- Total[Abs[{a - b, b - c, c - d, d - e, e - f, f - g, g - h}]] ==
- 35) &]
- sol3 = Select[
- sol2, ({a, b, c, d, e, f, g, h} = #;
- Mod[b, 2] == 0 && Mod[c, 3] > 0 (*&&etc*)) &]
- Select[sol3, ({a, b, c, d, e, f, g, h} = #;
- Abs[Total[{a, b, c, d}] - Total[{e, f, g, h}]] == 16) &]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement