Using the technique from http://mathisfunforum.com/viewtopic.php … 63#p265663, we can utilize a table instead, since recursion in this case is prohibitive.
k = 3 # a face appears k times
n = 10
throws = [[[[[[0]*n for _ in xrange(n)] for _ in xrange(n)] for _ in xrange(n)] for _ in xrange(n)] for _ in xrange(n)] # a 6-dimensional list
for a in range(k+1):
for b in range(k+1):
for c in range(k+1):
for d in range(k+1):
for e in range(k+1):
for f in range(k+1):
if (a == 0 or b == 0 or c == 0 or d == 0 or e == 0 or f == 0):
throws[a][b][c][d][e][f] = 6*k - (a+b+c+d+e+f)
else:
throws[a][b][c][d][e][f] = float(throws[a-1][b][c][d][e][f]+throws[a][b-1][c][d][e][f]+throws[a][b][c-1][d][e][f]+throws[a][b][c][d-1][e][f]+throws[a][b][c][d][e-1][f]+throws[a][b][c][d][e][f-1])/6
print throws[k][k][k][k][k][k]
Perhaps we can solve more problems involving trees this way.
]]>s=0;
fubar[L_]:=Module[{s=0,ans=L},
While[ans!={},
ans = RandomChoice[{1,2,3,4,5,6},Length[ans]];
If[Count[ans,2|5]==0,s+=Total[ans],ans=DeleteCases[ans,2|5]];
];
s]
Table[fubar[ RandomChoice[{1,2,3,4,5,6},5]],{100000}]//Mean//N
16.08264
All indentations for readability taken out.
This is a really poor effort and you should avoid programming in this manner.
]]>Know how to simulate or enumerate it?
How do I simulate it?
]]>Simulation checks out his answer.
]]>