Help:=proc():print(`Ini(n)`):end: #Ini(n): the initial state Ini:=proc(n,j) local i: if j=1 then [[seq(i,i=1..n)],[],[]]: elif j=2 then [[],[seq(i,i=1..n)],[]]: else [[],[],[seq(i,i=1..n)]]: end: #H(n,i,j): the list of states to save the world #for moving n rings from Tower i to Tower j H:=proc(n,i,j) local k,S1,S2,i1: if n=1 then [Ini(n,i),Ini(n,j)]: fi: k:=op(1,{1,2,3} minus {i,j}): S1:=H(n-1,i,k): if i=1 then S1:= [seq([[op(S1[i1][1]),n] ,S1[i1][2],S1[i1][3]],i1=1..nops(S1))]: elif i=2 then S1:= [S1[i][1] ,[op(S1[i1][2]),n] ,S1[i1][3]],i1=1..nops(S1))]: else S1:= [S1[i1][1], ,S1[i1][2], [op(S1[i1][3]),n)]],i1=1..nops(S1))]: fi: RETURN(S1): S2:=H(n-1,k,j): end: