Help:=proc(): print(`mex(S), g(G), g2(i,j) `): print(` g2(i,j) `): end: mex:=proc(S) local i: for i from 0 while member(i,S) do od: i: end: #g(G): given a directed graph G in the data structure #where the set of vertices is {1, ..., nops(G)} and #G[i] is the set of vertices reachable from i in one move #outputs the label of the Grundy function g:=proc(G) local T,A,V,v,v1,i: #A: set of vertices already labelled #T the table of Grundy function values #L vertices already labelled V:={seq(i,i=1..nops(G))}: A:={}: for i from 1 to nops(G) do if G[i]={} then T[i]:=0: A:=A union {i}: fi: od: while A<>V do for v in (V minus A) do if G[v] minus A={} then T[v]:=mex({seq(T[v1],v1 in G[v])}): A:=A union {v}: next: fi: od: od: [seq(T[i],i=1..nops(G))]: end: g2:=proc(i,j) local k: option remember: mex({seq(g2(k,j),k=0..i-1),seq(g2(i,k),k=0..j-1)}): end: