1. CountRuns:=proc(L,k) local i,ans: ans:=0; for i from 1 to nops(L)-k+1 do if nops({op(i..i+k-1,L)})=1 then ans++: fi: od: ans: end: 2. AvePathRuns:=proc(m,n,k,N) local i,L,r,s: s:=[]; for i from 1 to N do L:=RPath(m,n): r:=CountRuns(L,k): s:= [op(s),r]: od: print(Mean(s),StandardDeviation(s)): end: AvePathRuns(200, 200, 5, 3000) = 24.2226666666667, 7.47353357680266 Yes, usually around 24.3 for the mean and 7.5 for the standard deviation. 3. AveGPathRuns:=proc(m,n,k,N) local i,L,r,s: s:=[]; for i from 1 to N do L:=RGPath(m,n): r:=CountRuns(L,k): s:= [op(s),r]: od: print(Mean(s),StandardDeviation(s)): end: AveGPathRuns(200, 200, 5, 3000) = 24.1756666666667, 7.55803209651469 It is around the same. 4. CountMaximalRuns:=proc(L,k) local i,ans: ans:=0; for i from 2 to nops(L)-k do if nops({op(i..i+k-1,L)})=1 and L[i-1]<>L[i] and L[i+k]<>L[i] then ans++: fi: od: ans: end: AvePathMaximalRuns:=proc(m,n,k,N) local i,L,r,s: s:=[]; for i from 1 to N do L:=RPath(m,n): r:=CountMaximalRuns(L,k): s:= [op(s),r]: od: print(Mean(s),StandardDeviation(s)): end: AveGPathMaximalRuns:=proc(m,n,k,N) local i,L,r,s: s:=[]; for i from 1 to N do L:=RGPath(m,n): r:=CountMaximalRuns(L,k): s:= [op(s),r]: od: print(Mean(s),StandardDeviation(s)): end: AveGPathMaximalRuns(200, 200, 5, 3000) = 6.04766666666667, 2.32834740164846 5. GoodBrother:=proc(L) local i,C: C:=CycShi(L): for i from 1 to nops(C) do if C[i][nops(C)] = 1 then print(C[i]): fi: od: end: 6. if two cyclic shifts of such an L are identical, it means that there is some word w such that L is w repeated k times. The sum of L is k times the sum of w.