\\ A360420: Number of Z-frame polyominoes with n cells, reduced for symmetry. \\ PARI program and formulas by Andrew Howroyd, 2023. \\ Z-Frame polyominoes consist of a rectangle with rectangular parts cut out from the top-left and bottom-right corners. \\ Example: \\ O O O O \\ O O O O \\ O O O O O O \\ O O O O \\ \\ For the purposes of enumeration, rectangles with rectangular parts cut out from \\ the top-right and bottom-left corners will not be considered. (They are ofcoarse \\ in equal number). \\ It will be observed that a Z-frame polyomino when reflected in either diagonal \\ or rotated by 180 degrees, results in a Z-frame polyomino with the cut outs \\ in the same corners. \\ It will also be observed that every Z-frame polyomino either has at least \\ one row that is the full width or one column that is the full height of the \\ polyomino. It is also possible to have both (as in the illustration above). \\ Case that there is at least one complete row that has full width: \\ Start with a rectangle of width k and then add rectangles above and \\ below with width at most k-1. For solutions that are invariant under \\ a rotation of 180 degrees the two added rectangles must be equal. \\ G.f.: Sum_{k>=2} (x^k/(1-x^k)) * (B(k-1, x)^2 + B(k-1, x^2))/2 where B(k,x) = Sum_{j=1..k} x^j/(1-x^j). \\ This is the same g.f. as for A028247 (T-frame polyominoes). B(k, x) = sum(j=1, k, x^j/(1-x^j)) N(n) = sum(k=2, n, (x^k/(1-x^k)) * (B(k-1, x + O(x^(1+n-k)))^2 + B(k-1, x^2 + O(x^(1+n-k))))/2, O(x*x^n)) \\ The above must be corrected by subtracting half the number of Z-frame polyominos that have \\ both a complete row and complete column and which are not invariant under a diagonal reflection. \\ To enumerate solutions with both a complete row and complete column, start with \\ a rectangle of width k and then add rectangles above and below with width at \\ most k-1 and combined width of at least k+1. The second condition ensures that \\ there is some overlap. \\ For solutions that are invariant under a rotation of 180 degrees the two added \\ rectangles must be equal. Q(n) = sum(k=3, n\2, x^k/(1-x^k) * sum(j=2, k-1, x^j/(1-x^j)*sum(i=k-j+1, k-1, x^i/(1-x^i), O(x^(n-k-j+1))))) Qsym(n) =sum(k=3, n\2, x^k/(1-x^k) * sum(j=k\2+1, k-1, x^(2*j)/(1-x^(2*j)), O(x^(n-k+1)) )) \\ To enumerate solutions that are invariant under a diagonal reflection start with a square \\ and then either cut out two squares from the corners which need not be equal in size \\ or cut out two equal sized rectangles. The two cases are for the different diagonals. \\ The functions below are reduced for symmetry. Diag1(n)=sum(k=3, (n+5)\4, sum(j=1, k-2, sum(i=1+sqrtint(max(0,k^2-j^2-n-1)), min(j, k-j-1), x^(k^2-i^2-j^2)))) Diag2(n)=sum(k=3, sqrtint(2*n), sum(j=2, k-2, sum(i=1+max(0,k^2-n-1)\(2*j), min(j-1, k-j-1), x^(k^2-2*i*j)))) \\ Combined solution \\ N - ((Q + Qsym)/2 - (Diag1 + Diag2))/2 seq(n)={Vec(N(n) + (Diag1(n)+Diag2(n))/2 - (Q(n) + Qsym(n))/4, -n)} \\ End