For an integer , the tuple is written on a blackboard. On each turn, one can choose two numbers from the tuple such that their sum is a perfect square and swap them to obtain a new tuple. Find all integers for which all permutations of can appear on the blackboard in this way.
Problem 1788
Official solution
Given the problem, we start with the sequence on a blackboard. The challenge is to determine for which integers , it is possible to obtain every permutation of by repeatedly swapping two numbers whose sum is a perfect square.
First, examine the properties of perfect squares:
### Step 1: Understand the perfect squares
Perfect squares between 2 and need to be considered since possible sums of pairs from range from 3 to . Thus, the possible sums are up to the largest perfect square less than or equal to .
### Step 2: Swapping Criteria
Each swap involves two numbers and such that is a perfect square. The operation allows us to permute values if such sums are possible across all pairs .
### Step 3: Constraint Analysis
For the complete permutation capability, swapping operations should allow transpositions (swap of any two adjacent numbers). To check this:
- Swap Transpositions: For transposition , needs to be a perfect square. Therefore, we need to check:
### Step 4: Explore the Solution
Let's analyze specific values of .
For :
- Consider , then .
- Similarly for values , none of the values is a perfect square, indicating necessary pairs (for adjacent swaps) are not all squares.
### Conclusion:
After evaluating the interchange possibility, it can be determined that for , enough swaps can be accomplished to reach all permutations due to the nature of increments allowing reached sums within perfect squares. Otherwise, for , some crucial swaps remain impossible due to limited sums equaling perfect squares.
Thus, the answer is: