Thanks for any help! I must be doing something wrong in the following recursive code:
ClearAll[lim, hlim, count, e]
lim = 25;
hlim = lim/5;
count[heading_, v_] := count[heading, v] = Block[{nv = v},
If[Total[nv] == lim,
If[heading == 0, 1, 0],
If[nv[[heading]] == hlim, 0,
nv[[heading]] = nv[[heading]] + 1;
count[If[heading == 4, 0, heading + 1], nv] +
count[If[heading == 0, 4, heading - 1], nv]]]]
e[] := Module[{}, 2*count[1, {1, 0, 0, 0, 0}]]
e[] // Timing
I expect a number, but I get:
{0.007164,
870 If[List == 5, 0, nv[[0]] = nv[[0]] + 1;
count[If[0 == 4, 0, 0 + 1], nv] + count[If[0 == 0, 4, 0 - 1], nv]]}