# Edit Town and Simoleons 4: Solution Codex (GPT-6) provides the fixed-position construction, optimality proof, batched formulas, implementations, and verification. ## Personal Wealth and the Averaging Grid Let $k=p_1$ and $a=m_1/k$ . Define each resident's personal wealth as the mean of their household. A departing person leaves the source's remaining mean unchanged. Joining another household averages the wealth of the mover and all destination residents. Thus every legal move is a complete average of a subset of people. First relax the position limit to obtain an upper bound for all averaging operations. Then construct a sequence attaining that bound within the fixed positions. ## An Upper Bound for Every Editing Sequence This argument permits unequal current wealth among target members, so it applies to intermediate states as well. Sort everyone by nondecreasing wealth, labeling targets $T$ and outsiders $O$ . Whenever adjacent labels are $TO$ , average those two values and exchange their positions in the sorted list. Their values are equal afterward, so the list remains sorted. Continue until all $O$ labels precede all $T$ labels. Let $\Phi$ be the resulting target sum. **The choice of operations does not affect the result.** Each operation removes one label inversion. Two simultaneously available $TO$ pairs cannot overlap, so their operations commute. Induction on the number of inversions gives the same final wealth vector for every execution order. **Each operation does not decrease target wealth.** The target in a pair is no richer than the outsider. Thus $\Phi$ is at least the current target sum, and it is reachable in finitely many edits when positions are unrestricted. **No pairwise average increases $\Phi$ .** Fix the initial wealth ordering. The operations are then a fixed sequence of adjacent averaging matrices, making $\Phi$ linear in the initial coordinates. At the end, the target-sum coefficients in sorted order are $$0,0,\ldots,0,1,1,\ldots,1.$$ Propagating these coefficients backward averages adjacent coefficients at each step, preserving their nondecreasing order. A richer initial coordinate therefore has a coefficient at least as large as a poorer coordinate. Now continuously bring any two values $xm_1$ . Products can reach $10^{15}$ , so use 64-bit integers. Modular values cannot be used for wealth comparisons. Precompute inverses of $1,\ldots,r$ and use exponentiation for $k^{-1}$ and $2^{-k}$ . Here $k,r