This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A374526 #13 Jul 31 2024 11:09:04 %S A374526 2,7,7,2,45,254,212,1,650,19500,44463,899,20,4,24520,4347402,27123390, %T A374526 1978573,72427,7940,144,36,2625117,3107244605,53818094633,11242079280, %U A374526 512469215,35810192,1002242,148572,2304,576,836488618 %N A374526 Similar to A374525, but for each starting matrix with a choice of whether to sort by columns or rows first, such that the total number of sorting steps for this matrix is minimized. %C A374526 This irregular triangle, read by rows, has the same structure as that of A374525, but differs starting from row 3. %F A374526 T(n,0) = A089006(n). %F A374526 Sum_{k>=0} T(n,k) = 2^(n^2). %e A374526 The triangle begins %e A374526 \ k 0 1 2 3 4 5 6 7 %e A374526 n -------------------------------------------------------- %e A374526 1 | 2, %e A374526 2 | 7, 7, 2, %e A374526 3 | 45, 254, 212, 1, %e A374526 4 | 650, 19500, 44463, 899, 20, 4, %e A374526 5 | 24520, 4347402, 27123390, 1978573, 72427, 7940, 144, 36 %e A374526 . %e A374526 T(3,3) = 1 because only one ([1,1,0; 1,0,1; 0,1,0]) of the A374525(3,3) = 5 matrices needs 3 sort steps irrespective of the initial sorting direction, whereas the other 4 ([0,1,1; 1,1,0; 0,0,1], [1,0,1; 0,1,1; 1,0,0], [1,0,1; 1,1,0; 0,0,1], [1,1,0; 0,1,1; 1,0,0]) can be sorted in a single step by choosing the "better" direction. %e A374526 . %e A374526 Sorting by %e A374526 Rows Cols Rows Cols stable %e A374526 1 1 0 0 1 0 0 0 1 0 0 1 0 0 1 %e A374526 1 0 1 1 0 1 1 1 0 0 1 1 0 1 1 %e A374526 0 1 0 1 1 0 0 1 1 1 1 0 1 1 0 3 sort steps needed %e A374526 for both choices %e A374526 Cols Rows Cols Rows stable of initial sorting %e A374526 1 1 0 0 1 1 0 1 0 0 0 1 0 0 1 direction %e A374526 1 0 1 1 0 1 0 1 1 0 1 1 0 1 1 %e A374526 0 1 0 0 1 0 1 0 1 1 1 0 1 1 0 %e A374526 . %e A374526 Rows Cols stable Cols Rows Cols Rows stable %e A374526 0 1 1 0 0 1 0 0 1 | 0 1 1 0 1 1 0 1 0 0 0 1 0 0 1 %e A374526 1 1 0 0 1 1 0 1 1 | 1 1 0 1 0 1 0 1 1 0 1 1 0 1 1 %e A374526 0 0 1 1 1 0 1 1 0 | 0 0 1 0 1 0 1 0 1 1 1 0 1 1 0 %e A374526 . %e A374526 1 0 1 0 1 1 0 1 1 | 1 0 1 0 1 1 0 1 0 0 0 1 0 0 1 %e A374526 0 1 1 1 0 0 1 0 0 | 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 %e A374526 1 0 0 1 0 1 1 0 1 | 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 %e A374526 . %e A374526 1 0 1 0 0 1 0 0 1 | 1 0 1 0 1 1 0 1 0 0 0 1 0 0 1 %e A374526 1 1 0 1 0 1 1 0 1 | 1 1 0 1 0 1 0 1 1 0 1 1 0 1 1 %e A374526 0 0 1 1 1 1 1 1 1 | 0 0 1 0 1 0 1 0 1 1 1 0 1 1 0 %e A374526 . %e A374526 1 1 0 0 1 1 0 1 1 | 1 1 0 0 1 1 0 1 0 0 0 1 0 0 1 %e A374526 0 1 1 1 0 0 1 0 0 | 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 %e A374526 1 0 0 1 1 0 1 0 1 | 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 %e A374526 1 sort step needed 3 sort steps needed %e A374526 . %e A374526 T(4,5)=4, because there are 4 matrices needing 5 sort steps irrespective of the choice of the initial sorting direction. %e A374526 [1,1,0,1; 1,0,1,1; 0,1,1,0; 1,1,0,0], [1,1,1,0; 1,0,1,1; 0,1,0,1; 1,1,0,0], %e A374526 [1,1,0,1; 1,0,1,1; 1,1,0,0; 0,1,1,0], [1,1,1,0; 1,0,1,1; 1,1,0,0; 0,1,0,1]. %e A374526 Routes of sorting for the first of these matrices, both with 5 steps: %e A374526 Cols Rows Cols Rows Cols Rows stable %e A374526 1 1 0 1 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 %e A374526 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 %e A374526 0 1 1 0 1 1 0 0 1 0 1 1 1 1 0 1 1 0 1 0 1 0 0 1 1 0 0 1 %e A374526 1 1 0 0 0 1 0 1 1 1 0 0 1 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 %e A374526 or %e A374526 Rows Cols Rows Cols Rows Cols stable %e A374526 1 1 0 1 0 1 1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 %e A374526 1 0 1 1 1 0 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 %e A374526 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 %e A374526 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 %o A374526 (PARI) numberOfSortSteps(M, f) = {my(c=0, M1 = if (f == 0, vecsort(M), vecsort(M~)~)); if (M != M1, M = M1; c++); while (1, f = !f; M1 = if (f == 0, vecsort(M), vecsort(M~)~); if (M != M1, M = M1; c++, return(c)))}; %o A374526 minNumberOfSortSteps(M) = min(numberOfSortSteps(M, 0), numberOfSortSteps(M, 1)); %o A374526 a374526(n) = {my(v = vector(n*n), M = matrix(n,n)); while (1, v[minNumberOfSortSteps(M) + 1]++; for (i = 1, n, for (j = 1, n, if (M[i,j]++ == 1, break(2), M[i,j]=0); if (i == n && j == n, break(3))))); select(x->x>0, v)}; %Y A374526 Cf. A002416 (row sums), A089006 (column 0), A374525. %K A374526 nonn,tabf,hard,more %O A374526 1,1 %A A374526 _Markus Sigg_ and _Hugo Pfoertner_, Jul 24 2024