This script executes a staged exhaustive search to find a unique set of 20 distinct integer values (
The objective is to find a solution vector
-
Domain:
$1 \le a_i \le 25$ for all$i \in [0, 19]$ . -
Uniqueness: All 20 values (
$a_0, a_1, \dots, a_{19}$ ) must be distinct. -
Constraints: All 10 constraints (
$c_1$ through$c_{10}$ ) must evaluate to zero.
The script optimizes the search process by breaking it down into incremental stages, using the constraints to calculate dependent variables (e.g.,
The system requires that the absolute value of each expression equals zero, which simplifies the equations to the following 10 identities:
| Constraint | Simplified Equation | Notes |
|---|---|---|
| c1 | ||
| c2 | Requires |
|
| c3 | ||
| c4 | ||
| c5 | ||
| c6 | ||
| c7 | Requires |
|
| c8 | ||
| c9 | ||
| c10 |
The script uses four sets of partial solutions, where the final three sets build upon the previous ones, incorporating new constraints and pruning invalid paths.
-
Constraint Used:
$c_{10}$ - The set
S0is initialized with 20 valid triples$(a_3, a_{14}, a_{19})$ that satisfy$c_{10}$ and the range/distinctness rules for these three variables.
| Stage | New Constraint Added | Variables Solved/Calculated |
|---|---|---|
| S | Loops for |
|
| S2 | Loops for |
|
| S3 | Loops for |
-
Loops: The final search iterates through
$a_9, a_{12}, a_{17}$ . -
Calculation: All remaining variables (
$a_2, a_{10}, a_3, a_{13}, a_{18}$ ) are calculated from the remaining constraints ($c_8, c_3, c_1, c_4, c_9$ ). -
Final Checks: The script verifies:
-
Range: All 20 variables are
$1 \le a_i \le 25$ . - Uniqueness: All 20 variables are distinct.
-
Final Constraint: The unused constraint
$c_5$ must be satisfied. -
Global Test: The
test(sol)function confirms all 10 equations are zero.
-
Range: All 20 variables are
The script prints the sizes of the intermediate sets and the final solution(s) found in S4.
python3 main.py