with(group): G:=permgroup(36,{a=[[1,2]], b=[[seq(i,i=1..36)]]}): moves:=proc(zz) local perm,cycle,j,nummoves,nextcard,foundmate; # perm:=array[1..36]: for cycle in zz do for j from 1 to nops(cycle)-1 do perm[cycle[j]]:=cycle[j+1]:od: perm[cycle[nops(cycle)]]:=cycle[1]: od: # nummoves:=0: nextcard:=1: # while nextcard<=36 do foundmate:=FALSE: for j from 1 to nextcard-1 do if perm[nextcard]=perm[j] mod 18 then foundmate:=TRUE:fi: od: if foundmate=FALSE then nextcard:=nextcard+1: foundmate:=FALSE: for j from 1 to nextcard-1 do if perm[nextcard]=perm[j] mod 18 then foundmate:=TRUE:fi: od: fi: nummoves:=nummoves+1:nextcard:=nextcard+1: od: # RETURN(nummoves); end: numhands:=array(1..36); for i from 1 to 36 do numhands[i]:=0:od: for i from 1 to 1000 do x:=moves(RandElement(G)):numhands[x]:=numhands[x]+1:od: #Warning: first invocation of RandElement takes a long time. print(seq(numhands[i],i=1..36)); v--20 is mode 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 215, 262, 205, 177, 88, 23, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 A:=array[0..36, 0..36]; A := array[0 .. 36, 0 .. 36] for m from 0 to 36 do A[0,m]:=0:od: #no unknowns ought to mean m=0, too! for m from 1 to 36 do A[1,m]:=0:od:A[1,1]:=1: for n from 2 to 36 do for k from 0 to floor(18-n/2) do #actually only need k >= 9-n/2 m:=36-2*k-n: #since m <= 18 in actual play. A[n,m]:=1+(m/n)*A[n-1,m-1]+((n-m)/n/(n-1))*A[n-2,m] +((n-m)*(n-m-2)/n/(n-1))*A[n-2,m+2]+ ((n-m)*m/n/(n-1))*A[n-2,m]: od: od: for i from 0 to 10 do print(seq(A[i,(i mod 2)+2*j],j=0..18));od;