#OK to post homework #Zidong Zhang, 31/1/2021, Assignment 3 #NewUCG(n):that has the same input and output as UCG(n), but instead starts with the #vector [0$n] and keeps applying NEXG(w), always appending the new guy to the list. #Check that UCG(n)=NewUCG(n) are the same for n from 1 to 14. NewUCG := proc(n) local N,L,L1: N:=[]: L :=[0$n]: N:=[L]: L1:=NEXG(L): while L1 <> FAIL do N:=[op(N),L1]: L1:= NEXG(L1): od: N: end: #BoxG(L):that inputs a list of positive integers and outputs a list whose members are the #same as Box(L), but in such an order that when you go from one member to the next, it #only changes in one place ########this question I know how to solve it, but I don't know how to program it since ########I'm not good at recurtion formula. BoxG := proc(L) local k,i,L1,B1,j: if not type(L,list) then print(L, `should be a list `): RETURN(FAIL): fi: k:=nops(L): if k=0 then RETURN([[]]): fi: if not ({seq(type(L[i],integer),i=1..nops(L))}={true} and min(op(L))>=0) then print(`bad input`): RETURN(FAIL): fi: L1:=[op(1..k-1,L)]: B1:= BoxG(L1): end: #Tomorrow(Date), Yesterday(Date)that inputs four-tupleDate=[DayOfTheMonth , Month , #Year, DayOfTheWeek ]and outputs the dates of the next day, and previous day, #respectively. ###########I don't know how to deal with the week part. ############### Tomorrow := proc(L) local ndom,nm,ny,nw,dom,m,y,dow: dom:=L[1]: m:=L[2]: y:=L[3]: dow:=L[4]: if ( m= odd or m= 8 or m=10 or m=12) then if dom +1 > 31 then ndom:=1: nm:= m+1: else ndom:=dom+1: nm:=m: fi: elif m=2 then if y mod 4 = 0 then if dom+1>29 then nm:=m+1: ndom:= 1: else nm:=m: ndom:=dom+1: fi: else if dom+1>28 then nm:= m+1: ndom:=1: else nm:=m: ndom:=dom+1: fi: fi: else if dom +1 > 31 then ndom:=1: nm:= m+1: else ndom:=dom+1: nm:=m: fi: fi: if nm>12 then ny:= y+1: else ny:= y: fi: [ndom,nm,ny,dow]: end: