#Class 1, math640, Rutgers Univerity, Fall 2016, Dr. Z. Help:=proc() print(`A(t), W(n) , w(n), IsC(L), SW(n) `):end: A:=proc(P,t) print(P , `Loves ExpMath in time`, t):end: #W(n): the set of Lattice walks with n steps in the 2D lattice #1:East, -1:West 2:North -2: South W:=proc(n) local S,P,s,p: option remember: S:={-1,1,2,-2}: if n=0 then RETURN({[]}): fi: P:=W(n-1): {seq(seq([op(p), s ], p in P), s in S)}: end: #w(n): a highly advanced fast way to compute nops(W(n)) w:=proc(n) option remember: if n=0 then 1: else 4*w(n-1): fi: end: #IsCycle(L): inputs a list L in {-1,1,2,-2} and outputs #true iff the number of 1's equals the number of -1'seq and ditto for 2 #IsC(): Is C a cycle (Richard Voepel's suggestion) IsC:=proc(L): evalb(convert(subs({2=I,-2=-I},L),`+`)=0): end: #SW(n): the set of Self-Avoiding Lattice walks with n steps in the 2D lattice #1:East, -1:West 2:North -2: South SW:=proc(n) local S,P,s,p,N,hope: option remember: S:={-1,1,2,-2}: if n=0 then RETURN({[]}): fi: P:=SW(n-1): N:={}: for p in P do for s in S do hope:=[op(p),s]: if not member(true,{seq(IsC([op(n-2*i+1..n,hope)]),i=1..n/2)}) then N:=N union {hope}: fi: od: od: N: end: