4-rings or 4-squares puzzle: Difference between revisions

no edit summary
No edit summary
Line 3,403:
There are 4 unique solutions in [3, 9]
There are 2860 non-unique solutions in [0, 9]</pre>
 
=={{header|Mathematica}}==
<lang Mathematica>{low, high} = {1, 7};
SolveValues[{a + b == b + c + d == d + e + f == f + g, low <= a <= high,
low <= b <= high, low <= c <= high, low <= d <= high,
low <= e <= high, low <= f <= high, low <= g <= high,
a != b != c != d != e != f != g}, {a, b, c, d, e, f, g}, Integers]
 
{low, high} = {3, 9};
SolveValues[{a + b == b + c + d == d + e + f == f + g, low <= a <= high,
low <= b <= high, low <= c <= high, low <= d <= high,
low <= e <= high, low <= f <= high, low <= g <= high,
a != b != c != d != e != f != g}, {a, b, c, d, e, f, g}, Integers]
 
{low, high} = {0, 9};
SolveValues[{a + b == b + c + d == d + e + f == f + g, low <= a <= high,
low <= b <= high, low <= c <= high, low <= d <= high,
low <= e <= high, low <= f <= high, low <= g <= high}, {a, b, c, d,
e, f, g}, Integers] // Length</lang>
{{out}}
<pre>{{3, 7, 2, 1, 5, 4, 6}, {4, 5, 3, 1, 6, 2, 7}, {4, 7, 1, 3, 2, 6,
5}, {5, 6, 2, 3, 1, 7, 4}, {6, 4, 1, 5, 2, 3, 7}, {6, 4, 5, 1, 2, 7,
3}, {7, 2, 6, 1, 3, 5, 4}, {7, 3, 2, 5, 1, 4, 6}}
 
{{7, 8, 3, 4, 5, 6, 9}, {8, 7, 3, 5, 4, 6, 9}, {9, 6, 4, 5, 3, 7,
8}, {9, 6, 5, 4, 3, 8, 7}}
 
2860</pre>
 
=={{header|Modula-2}}==
1,111

edits