Cut a rectangle: Difference between revisions

m
→‎optimized: simplified the code in the SOLVE function.
(→‎optimized: added some optimizations, incorporated a formula for calculating the number of cuts when M is even and N is equal to 3.)
m (→‎optimized: simplified the code in the SOLVE function.)
Line 2,831:
solve: procedure expose # @. dir. h len next. w; @.= 0 /*zero rectangle coördinates.*/
parse arg h,w,recur /*get values for some args. */
if w==3 then if h>3 then do; z= h % 2 + 2; return 2**z - (z + z) + 1
end
if h//2 then do; t= w; w= h; h= t; if h//2 then return 0
end