Help14:=proc(): print(` LC(p) , LDie(A), Paths(m,n), GPaths(m,n), NuPaths(m,n), NuGPaths(m,n) , RPath(m,n) , CycShi(L) , DvoMot(n), DrawP(P) `): end: #LC(p): inputs a rational number p outputs 1 with probability p (and 0 otherwise) #LC is short for "Loaded Coin" LC:=proc(p) local a,b,r: a:=numer(p): b:=denom(p): r:=rand(1..b)(): if r<=a then RETURN(1): else RETURN(0): fi: end: #LDie(A): inputs a list of non-negative integers [a[1],..., a[k]] (say) outputs i with probability a[i]/(a[1]+...+a[k]). Try #LDie([1,2,3]); #LDie is short for "Loaded die" LDie:=proc(A) local N,i,j,r: N:=add(A[i],i=1..nops(A)): r:=rand(1..N)(): for i from 1 to nops(A) while add(A[j],j=1..i-1)=n GPaths:=proc(m,n) local S1,S2,s: option remember: if ( m<0 or n<0 or m2*n+1 then print(`Something is wrong`): RETURN(false): fi: od: #We now check that the union of the cyclic shifts of the members of S is Paths(n+1,n) evalb({seq(op(CycShi(s)), s in S)}=Paths(n+1,n)): end: #DrawP(P): Draws the path P DrawP:=proc(P) local P1,Pt,i: P1:=[[0,0]]: Pt:=[0,0]: for i from 1 to nops(P) do if P[i]=1 then Pt:=Pt+[1,0]: else Pt:=Pt+[0,1]: fi: P1:=[op(P1),Pt]: od: plot(P1,axes=none): end: