#IsGood1(T): Given a potential trapezoid (in the right-angled format) # that you know that its horiz. , vertical #and its NW->SE diagonals for the truncated version (where you chopped #the last row), returns true iff the new one is also OK #Try: #IsGood1([[1,2,3],[2,1]]); IsGood1:=proc(T) local n,k,i: k:=nops(T): n:=nops(T[1]): for i from 1 to nops(T[k]) do #checking that all NW->SW diagonals are OK if member(T[k][i],{seq(T[k-j][i+j],j=1..k-1)}) then RETURN(false): fi: #Checking that all vertical lines are distinct if member(T[k][i],{seq(T[j][i],j=1..k-1)}) then RETURN(false): fi: od: true: end: #LT(n,k): The SET OF REDUCED n by k LATIN TRAPEZOIDS #The bottom line is 1,...,n, and each floor above it #of length n-1,n-2, .., n-k+1 has all DIFFERENT entries #also VERTICALLY all different also A[i][i],A[i+1][i+1], ... are #all different LT:=proc(n,k) local S, Sold,PNF,old1,f,new1: option remember: if k=1 then RETURN({[[seq(i,i=1..n)]]}): fi: Sold:=LT(n,k-1): PNF:=permute(n,n-k+1): S:={}: for old1 in Sold do for f in PNF do new1:=[op(old1),f]: if IsGood1(new1) then S:=S union {new1}: fi: od: od: S: end: