#Homework by Mike Murr #OK to post #hw25 read(`C25.txt`); #HookSet(L,cell) Inputs a shape L and a cell [i,j], with 1<=i<=nops(L), 1<=j<=L[i], # and outputs the set of all cells that are (weakly) to the right in the same row, # and (weakly) down in the same column. HookSet:=proc(L, cell) local i, j, S, jj, ii; if nops(cell) <> 2 then print(`cell should be a list of 2 positive integers`); return(FAIL); fi; i:=cell[1]; if i > nops(L) then return({}); fi; j:=cell[2]; if j > L[i] then return({}); fi; S:={}; for jj from j to L[i] do S:=S union {[i,jj]}; od; for ii from i to nops(L) while j <= L[ii] do S:=S union {[ii,j]}; od; print(S); end proc; HookSet([5,5,3,2,1],[2,2]);