OFFSET
0,5
COMMENTS
These are the Grundy values or nim-values for heaps of n beans in the game where you're allowed to take up to half of the beans in a heap and you can use a one-time pass, i.e., a pass move which may be used at most once in a game, and not from a terminal position. Once the pass has been used by either player, it is no longer available. If the pass move were not allowed, then this game would be the same as the one in A025480.
FORMULA
a(4k) = 2k+1; a(4k+2) = 2k; a(4k+3) = a(2k+1); a(8k+1) = 2k+1; a(8k+5) = 2k.
MATHEMATICA
f[n_] := Which[IntegerQ[n/4], (n + 2)/2, IntegerQ[(n - 2)/4], (n - 2)/2,
IntegerQ[(n - 3)/4], f[(n - 1)/2], IntegerQ[(n - 1)/8], (n + 3)/4,
IntegerQ[(n - 5)/8], (n - 5)/4];
(* the following is Mathematica program to generate the same sequence as Grundy numbers *)
ss = 50; allcases = Flatten[Table[Table[{a, pass}, {a, 0, ss}], {pass, 0, 1}], 1];
move[z_] := Block[{p}, p = z;
a = p[[1]]; pass = p[[2]]; c0 = Floor[a/2];
Which[a > 0 && pass == 1,
Union[Table[{a - x, pass}, {x, 1, c0}], {{a, 0}}], a > 0,
Table[{a - x, pass}, {x, 1, c0}], a == 0, {}]];
Mex[L_] := Min[Complement[Range[0, Length[L]], L]];
Gr2[pos_] := Gr2[pos] = Mex[Map[Gr2, move[pos]]];
pposition = Select[allcases, Gr2[#] == 0 &];
Table[Gr2[{n, 1}], {n, 0, 50}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Ryouhei Miyadera, Mariko Kashihara and Koh Oomori, Nov 12 2012
STATUS
approved