==> competition/games/nim.s <== For the particular game described we only need to consider positions for which the following condition holds for each pile: (number of bills in pile k) + k >= (number of piles) + 1 A GOOD position is defined as one in which this condition holds, with equality applying only to one pile P, and all piles following P having the same number of bills as P. ( So the initial position is GOOD, the special pile being the first. ) I now claim that if I leave you a GOOD position, and you make any move, I can move back to a GOOD position. Suppose there are n piles and the special pile is numbered (n-p+1) (so that the last p piles each contain p bills). (1) You take p bills from p or more piles; (a) If p = n, you have just taken the last bill and lost. (b) Otherwise I reduce pile (n-p) (which is now the last) to 1 bill. (2) You take p bills from r(p; I take (p-q) bills from (q+r-p) piles (b) q+r<=p; I take (p-q) bills from (q+r) piles Verifying that each of the resulting positions is GOOD is tedious but straightforward. It is left as an exercise for the reader. -- RobH