Ordering states for an integer-incrementing game.

53 Views Asked by At

There is a game played with a one-dimensional array of non-negative integers such as

$$\underline{1}\;\underline{2}\;\underline{0}\;\underline{0}\;\underline{1}$$

Given such an array of $n$ numbers, you may: (1) decrement one of the integers and increment the neighbor to its right; or (2) increment any of the numbers. For example:

$$\underline{1}\;\underline{\color{skyblue} 2}\;\underline{0}\;\underline{0}\;\underline{1} \;\rightarrow\; \underline{1}\;\underline{\color{skyblue} 1}\;\underline{\color{skyblue} 1}\;\underline{0}\;\underline{1}$$

$$\underline{1}\;\underline{\color{skyblue} 2}\;\underline{0}\;\underline{0}\;\underline{1} \;\rightarrow\; \underline{1}\;\underline{\color{skyblue} 3}\;\underline{0}\;\underline{0}\;\underline{1}$$

These two operations induce a partial order on arrays of integers, where one array precedes another if you can transform it into the other by applying some sequence of these operations. Some arrays are incomparable; for example these two:

$$\underline{1}\;\underline{0}\;\underline{0}\;\underline{1}\;\underline{0} \;\qquad\; \underline{0}\;\underline{1}\;\underline{1}\;\underline{0}\;\underline{0}$$


Given two same-length arrays, I'm looking for a procedure to determine whether one array precedes another (or if they're incomparable). I've tried to look for invariants, for example by looking at the cumulative sums from left to right, but haven't found one yet.

1

There are 1 best solutions below

0
On BEST ANSWER

Let $A$ and $B$ be two same-length arrays, and let $C=A-B$. Consider the accumulated sums of $C$ from right to left: if the accumulated sums are all non-negative, then $A$ follows $B$. If they're all non-positive, then $B$ follows $A$. (Hence if they're all zero, then $A=B$.) If they're a mix of positive and negative, $A$ and $B$ are incomparable.

The reason these cumulated sums are the right representation is because they ensure that however many "minuses" you encounter in the array, they are offset by at least as many pluses further to the right.