#Please do not post homework #AJ Bu, April 22 2021, Assignment 25 #################### PROBLEM 1 #################### #HookSet(L,cell): inputs a shape L and a cell [i,j], with 1≤ i ≤nops(L), #1 ≤ j ≤ L[i], and outputs set 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 k: k:=nops(L): while L[k]n2 do if corners[i][2]=corners[i+1][2] then corners:=corners minus {corners[i]}: n1:=n1-1: else i:=i+1: fi: od: while not member(cell,corners) do H1:=HookSet(L,cell) minus {cell}: k:=nops(H1): r:=rand(1..k)(): cell:=H1[r]: od: cell: end: #################### PROBLEM 3 #################### GNW:=proc(L) local n,T,L1,cell: n:=add(L): T:=[seq([seq(0,j=1..L[i])],i=1..nops(L))]: L1:=L: while n<>0 do cell:=OneStepGNW(L1): T:=[ op( T[1..cell[1]-1]),[ op(T[cell[1]][1..cell[2]-1]),n, op( T[cell[1]][cell[2]+1..nops(T[cell[1]])]) ], op( T[cell[1]+1..nops(T)])]: L1:=[op( L1[1..cell[1]-1]), L1[cell[1]]-1, op( L1[ cell[1]+1..nops(L1) ] )]: n:=n-1: od: T: end: #it took 0 seconds. #################### PROBLEM 4 #################### #See attached PDF