#John Kim #Use whatever you like #read "C:/Users/John Y. Kim/Documents/Maple/hw22.txt": split:=proc(L,R) local n,m: if nops(L)=0 or nops(R)=0 then RETURN(false): fi: n:=op(nops(L),L): m:=op(1,R): if n=m then RETURN(false): fi: if n>=4 and m<=3 then RETURN(true): fi: if n=2 then if m=1 and nops(R)>2 and op(2,R)<>1 and op(3,R)<>op(2,R) then RETURN(true): fi: if m=1 and nops(R)=2 and op(2,R)<>1 then RETURN(true): fi: if m=1 and nops(R)>=3 and op(2,R)=1 and op(3,R)=1 then RETURN(true): fi: if m=3 and nops(R)>=2 and op(2,R)<>3 and not(nops(R)>=4 and op(2,R)=op(3,R) and op(3,R)=op(4,R)) then RETURN(true): fi: if m=3 and nops(R)=1 then RETURN(true): fi: if m>=4 then RETURN(true): fi: fi: if n<>2 then if nops(R)>=5 and op(1,R)=2 and op(2,R)=2 and op(3,R)=1 and op(4,R)<>1 and op(5,R)<>op(4,R) then RETURN(true): fi: if nops(R)=4 and op(1,R)=2 and op(2,R)=2 and op(3,R)=1 and op(4,R)<>1 then RETURN(true): fi: if nops(R)>=5 and op(1,R)=2 and op(2,R)=2 and op(3,R)=1 and op(4,R)=1 and op(5,R)=1 then RETURN(true): fi: if nops(true)>=4 and op(1,R)=2 and op(2,R)=2 and op(3,R)=3 and op(4,R)<>op(3,R) and not(nops(R)>=6 and op(4,R)=op(5,R) and op(5,R)=op(6,R)) then RETURN(true): fi: if nops(R)=2 and op(1,R)=2 and op(2,R)=2 then RETURN(true): fi: if nops(R)=3 and op(1,R)=2 and op(2,R)=2 and op(3,R)>=4 then RETURN(true): fi: if nops(R)>=3 and op(1,R)=2 and op(2,R)=2 and op(3,R)>=4 and op(4,R)<>op(3,R) then RETURN(true): fi: fi: false: end: #IsAtom(L): inputs a list in {1,2,3}*, L, and outputs true #iff L is an atom. IsAtom:=proc(L) local i: if L=[] then false: elif L=[3] then true: elif L=[1] or L=[2] then false: else for i from 1 to nops(L)-1 do if split(L[1..i],L[i+1..nops(L)]) then RETURN(false): fi: od: RETURN(true): fi: end: #SplitUp(L): inputs a list in {1,2,3}*, L, and outputs it as a #list of lists #[L1,L2,L3, ...] #where L=[op(L1),op(L2), op(L3), ...] #and L1,L2,L3,... are atoms. SplitUp:=proc(L) local i,L1,Lrest: option remember: if IsAtom(L) then RETURN([L]): fi: for i from 1 to nops(L)-1 do L1:=L[1..i]: Lrest:=L[i+1..nops(L)]: if split(L1,Lrest) then RETURN([L1,op(SplitUp(Lrest))]): fi: od: end: