cp's OEIS Frontend

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.

Showing 1-8 of 8 results.

A269526 Square array T(n,k) (n>=1, k>=1) read by antidiagonals upwards in which each term is the least positive integer satisfying the condition that no row, column, diagonal, or antidiagonal contains a repeated term.

Original entry on oeis.org

1, 2, 3, 3, 4, 2, 4, 1, 5, 6, 5, 2, 6, 1, 4, 6, 7, 3, 2, 8, 5, 7, 8, 1, 5, 9, 3, 10, 8, 5, 9, 4, 1, 7, 6, 11, 9, 6, 4, 7, 2, 8, 5, 12, 13, 10, 11, 7, 3, 5, 6, 9, 4, 14, 8, 11, 12, 8, 9, 6, 10, 3, 7, 15, 16, 14, 12, 9, 13, 10, 11, 14, 4, 15, 16, 17, 7, 18, 13, 10, 14, 11, 3, 4, 8, 16, 9, 6, 12, 15, 7
Offset: 1

Views

Author

Alec Jones, Apr 07 2016

Keywords

Comments

An infinite Sudoku-type array.
In the definition, "diagonal" means a diagonal line of slope -1, and "antidiagonal" means a diagonal line of slope +1.
Theorem C (Bob Selcoe, Jul 01 2016): Every column is a permutation of the natural numbers.
Proof: Fix k, and suppose j is the smallest number missing from that column. For this to happen, every entry T(n,k) for sufficiently large n in that column must see a j in the NW diagonal through that cell or in the row to the W of that cell. But there are at most k-1 copies of j in the columns to the left of the k-th column, and if n is very large the entry T(n,k) will be unaffected by those j's, and so T(n,k) would then be set to j, a contradiction. QED
Theorem R (Rob Pratt, Bob Selcoe, N. J. A. Sloane, Jul 02 2016): Every row is a permutation of the natural numbers.
Proof: Fix n, and suppose j is the smallest number missing from that row. For this to happen, every entry T(n,k) for sufficiently large k in that row must see a j in the column to the N, or in the NW diagonal through that cell or in the SW diagonal through that cell.
Rows 1 through n-1 contain at most n-1 copies of j, and their influence on the entries in the n-th row only extend out to the entry T(n,k_0), say. We take k to be much larger than k_0 and consider the entry T(n,k). We will show that for large enough k it can (and therefore must) be equal to j, which is a contradiction.
Consider the triangle bounded by row n, column 1, and the SW antidiagonal through cell (n,k). Replace every copy of j in this triangle by a queen and think of these cells as a triangular chessboard. These are non-attacking queens, by definition of the sequence, and by the result in A274616 there can be at most 2*k/3 + 1 such queens. However, there are k-k_0 cells in row n that have to be attacked, and for large k this is impossible since k-k_0 > 2*k/3+1. If a cell (n,k) is not attacked by a queen, then T(n,k) can take the value j. QED
Presumably every diagonal is also a permutation of the natural numbers, but the proof does not seem so straightforward. Of course the antidiagonals are not permutations of the natural numbers, since they are finite in length. - N. J. A. Sloane, Jul 02 2016
For an interpretation of this array in terms of Sprague-Grundy values, see A274528.
From Don Reble, Jun 30 2016: (Start)
Let b(n) be the position in column n where 1 appears, i.e., such that T(b(n),n) = 1. Then b(n) is A065188, which is Antti Karttunen's "Greedy Queens" permutation.
Let b'(n) be the position in row n where 1 appears, i.e., such that T(n,b'(n)) = 1. Then b'(n) is A065189, the inverse "Greedy Queens" permutation. (End)
The same sequence arises if we construct a triangle, by reading from left to right in each row, always choosing the smallest positive number which does not produce a duplicate number in any row or diagonal. - N. J. A. Sloane, Jul 02 2016
It appears that the numbers generally appear for the first time in or near the first few rows. - Omar E. Pol, Jul 03 2016
The last comment in the FORMULA section seems wrong: It seems that columns 4, 5, 6, 7, 8, 9, ...(?) all have first differences which become 16-periodic from, respectively, term 8, 17, 52, 91, 92, 131, ... on, rather than having period 4^(k-1) from term k on. - M. F. Hasler, Sep 26 2022

Examples

			The array is constructed along its antidiagonals, in the following way:
  a(1)  a(3)  a(6)  a(10)
  a(2)  a(5)  a(9)
  a(4)  a(8)
  a(7)
See the link from Peter Kagey for an animated example.
The beginning of the square array is:
   1,  3,  2,  6,  4,  5, 10, 11, 13,  8, 14, 18,  7, 20, 19,  9, 12, ...
   2,  4,  5,  1,  8,  3,  6, 12, 14, 16,  7, 15, 17,  9, 22, 21, 11, ...
   3,  1,  6,  2,  9,  7,  5,  4, 15, 17, 12, 19, 18, 21,  8, 10, 23, ...
   4,  2,  3,  5,  1,  8,  9,  7, 16,  6, 18, 17, 11, 10, 23, 22, 14, ...
   5,  7,  1,  4,  2,  6,  3, 15,  9, 10, 13,  8, 20, 14, 12, 11, 17, ...
   6,  8,  9,  7,  5, 10,  4, 16,  2,  1,  3, 11, 22, 15, 24, 13, 27, ...
   7,  5,  4,  3,  6, 14,  8,  9, 11, 18,  2, 21,  1, 16, 10, 12, 20, ...
   8,  6,  7,  9, 11,  4, 13,  3, 12, 15,  1, 10,  2,  5, 26, 14, 18, ...
   9, 11,  8, 10,  3,  1, 14,  6,  7, 13,  4, 12, 24, 18,  2,  5, 19, ...
  10, 12, 13, 11, 16,  2, 17,  5, 20,  9,  8, 14,  4,  6,  1,  7,  3, ...
  11,  9, 14, 12, 10, 15,  1,  8, 21,  7, 16, 20,  5,  3, 18, 17, 32, ...
  12, 10, 11,  8,  7,  9,  2, 13,  5, 23, 25, 26, 14, 17, 16, 15, 33, ...
...
  - _N. J. A. Sloane_, Jun 29 2016
		

Crossrefs

First 4 rows are A274315, A274316, A274317, A274791.
Main diagonal is A274318.
Column 1 is A000027, column 2 is A256008(n) = A004443(n-1)+1 = 1 + (nimsum of n-1 and 2), column 3 is A274614 (or equally, A274615 + 1), and column 4 is A274617 (or equally, A274619 + 1).
Antidiagonal sums give A274530. Other properties of antidiagonals: A274529, A275883.
Cf. A274080 (used in Haskell program), A274616.
A065188 and A065189 say where the 1's appear in successive columns and rows.
If all terms are reduced by 1 and the offset is changed to 0 we get A274528.
A274650 and A274651 are triangles in the shape of a right triangle and with a similar definition.
See A274630 for the case where both queens' and knights' moves must avoid duplicates.

Programs

  • Haskell
    import Data.List ((\\))
    a269526 n = head $ [1..] \\ map a269526 (a274080_row n)
    -- Peter Kagey, Jun 10 2016
    
  • Maple
    # The following Maple program was provided at my request by Alois P. Heinz, who said that he had not posted it himself because it stores the data in an inefficient way. - N. J. A. Sloane, Jul 01 2016
    A:= proc(n, k) option remember; local m, s;
             if n=1 and k=1 then 1
           else s:= {seq(A(i,k), i=1..n-1),
                     seq(A(n,j), j=1..k-1),
                     seq(A(n-t,k-t), t=1..min(n,k)-1),
                     seq(A(n+j,k-j), j=1..k-1)};
                for m while m in s do od; m
             fi
         end:
    [seq(seq(A(1+d-k, k), k=1..d), d=1..15)];
  • Mathematica
    A[n_, k_] := A[n, k] = If[n == 1 && k == 1, 1, s = {Table[A[i, k], {i, 1, n-1}], Table[A[n, j], {j, 1, k-1}], Table[A[n-t, k-t], {t, 1, Min[n, k] - 1}], Table[A[n+j, k-j], {j, 1, k-1}]} // Flatten; For[m = 1, True, m++, If[FreeQ[s, m], Return[m]]]];
    Table[Table[A[1+d-k, k], {k, 1, d}], {d, 1, 15}] // Flatten (* Jean-François Alcover, Jul 21 2016, translated from Maple *)
  • PARI
    {M269526=Map(); A269526=T(r,c)=c>1 && !mapisdefined(M269526, [r,c], &r) && mapput(M269526, [r,c], r=sum(k=1, #c=Set(concat([[T(r+k,c+k)|k<-[1-min(r, c)..-1]], [T(r,k)|k<-[1..c-1]], [T(k,c)|k<-[1..r-1]], [T(r+c-k,k)|k<-[1..c-1]]])), c[k]==k)+1); r} \\ M. F. Hasler, Sep 26 2022

Formula

Theorem 1: T(n,1) = n.
Proof by induction. T(1,1)=1 by definition. When calculating T(n,1), the only constraint is that it be different from all earlier entries in the first column, which are 1,2,3,...,n-1. So T(n,1)=n. QED
Theorem 2 (Based on a message from Bob Selcoe, Jun 29 2016): Write n = 4t+i with t >= 0, i=1,2,3, or 4. Then T(n,2) = 4t+3 if i=1, 4t+4 if i=2, 4t+1 if i=3, 4t+2 if i=4. This implies that the second column is the permutation A256008.
Proof: We check that the first 4 entries in column 2 are 2,5,6,3. From then on, to calculate the entry T(n,2), we need only look to the N, NW, W, and SW (we need never look to the East). After we have found the first 4t entries in the column, the column contains all the numbers from 1 to 4t. The four smallest free numbers are 4t+1, 4t+2, 4t+3, 4t+4. Entry T(4t+1,2) cannot be 4t+1 or 4t+2, but it can (and therefore must) be 4t+3. Similarly T(4t+2,2)=4t+4, T(4t+3,2)=4t+1, and T(4t+4,2)=4t+2. The column now contains all the numbers from 1 to 4t+4. Repeating this argument established the theorem. QED
Comments from Bob Selcoe, Jun 29 2016: (Start)
From Theorem 2, column 2 (i.e., terms a((j^2+j+4)/2), j>=1) is a permutation. After a(3)=3, the differences of successive terms follow the pattern a(n) = 3 [+1, -3, +1, +5], so a(5)=4, a(8)=1, a(12)=2, a(17)=7, a(23)=8, a(30)=5...
Similarly, column 3 (i.e., terms a((j^2+j+6)/2), j>=2) appears to be a permutation, but with the pattern after a(6)=2 and a(9)=5 being 5 [+1, -3, -2, +8, -5, +3, +1, +5, +1, -3, +1, -2, +8, -3, +1, +5]. (See A274614 and A274615.)
I conjecture that other similar cyclical difference patterns should hold for any column k (i.e., terms a((j^2+j+2*k)/2), j>=k-1), so that each column is a permutation.
Also, the differences in column 1 are a 1-cycle ([+1]), in column 2 a 4-cycle after the first term, and in column 3 a 16-cycle after the second term. Perhaps the cycle lengths are 4^(k-1) starting after j=k-1. (End) WARNING: These comments may be wrong - see COMMENTS section. - N. J. A. Sloane, Sep 26 2022

Extensions

Definition clarified by Omar E. Pol, Jun 29 2016

A274650 Triangle read by rows: T(n,k), (0 <= k <= n), in which each term is the least nonnegative integer such that no row, column, diagonal, or antidiagonal contains a repeated term.

Original entry on oeis.org

0, 1, 2, 3, 0, 1, 2, 4, 3, 5, 5, 1, 0, 2, 3, 4, 3, 5, 1, 6, 7, 6, 7, 2, 0, 5, 4, 8, 8, 5, 9, 4, 7, 2, 10, 6, 7, 10, 8, 3, 0, 6, 9, 5, 4, 11, 6, 12, 7, 1, 8, 3, 10, 9, 13, 9, 8, 4, 11, 2, 0, 1, 12, 6, 7, 10, 10, 11, 7, 12, 4, 3, 2, 9, 8, 14, 13, 15, 12, 9, 10, 6, 8, 1, 0, 11, 7, 4, 16, 14, 17
Offset: 0

Views

Author

Omar E. Pol, Jul 02 2016

Keywords

Comments

Similar to A274528, but the triangle here is a right triangle.
The same rule applied to an equilateral triangle gives A274528.
By analogy, the offset for both rows and columns is the same as the offset of A274528.
We construct the triangle by reading from left to right in each row, starting with T(0,0) = 0.
Presumably every diagonal and every column is also a permutation of the nonnegative integers, but the proof does not seem so straightforward. Of course neither the rows nor the antidiagonals are permutations of the nonnegative integers, since they are finite in length.
Omar E. Pol's conjecture that every column and every diagonal of the triangle is a permutation of the nonnegative integers is true: see the link. - N. J. A. Sloane, Jun 07 2017
It appears that the numbers generally appear for the first time in or near the right border of the triangle.
Theorem 1: the middle diagonal gives A000004 (the zero sequence).
Proof: T(0,0) = 0 by definition. For the next rows we have that in row 1 there are no zeros because the first term belongs to a column that contains a zero and the second term belongs to a diagonal that contains a zero. In row 2 the unique zero is T(2,1) = 0 because the preceding term belongs to a column that contains a zero and the following term belongs to a diagonal that contains a zero. Then we have two recurrences for all rows of the triangle:
a) If T(n,k) = 0 then row n+1 does not contain a zero because every term belongs to a column that contains a zero or it belongs to a diagonal that contains a zero.
b) If T(n,k) = 0 the next zero is T(n+2,k+1) because every preceding term in row n+2 is a positive integer because it belongs to a column that contains a zero and, on the other hand, the column, the diagonal and the antidiagonal of T(n+2,k+1) do not contain zeros.
Finally, since both T(n,k) = 0 and T(n+2,k+1) = 0 are located in the middle diagonal, the other terms of the middle diagonal are zeros, or in other words: the middle diagonal gives A000004 (the zero sequence). QED
Theorem 2: all zeros are in the middle diagonal.
Proof: consider the first n rows of the triangle. Every element located above or at the right-hand side of the middle diagonal must be positive because it belongs to a diagonal that contains one of the zeros of the middle diagonal. On the other hand every element located below the middle diagonal must be positive because it belongs to a column that contains one of the zeros of the middle diagonal, hence there are no zeros outside of the middle diagonal, or in other words: all zeros are in the middle diagonal. QED
From Hartmut F. W. Hoft, Jun 12 2017: (Start)
T(2k,k) = 0, for all k >= 0, and T(n,{(n-1)/2,(n+2)/2,(n-2)/2,(n+1)/2}) = 1, for all n >= 0 with n mod 8 = {1,2,4,5} respectively, and no 0's or 1's occur in other positions. The triangle of positions of 0's and 1's for this sequence is the triangle in the Comment section of A274651 with row and column indices and values shifted down by one.
The sequence of rows containing 1's is A047613 (n mod 8 = {1,2,4,5}), those containing only 1's is A016813 (n mod 8 = {1,5}), those containing both 0's and 1's is A047463 (n mod 8 = {2,4}), those containing only 0's is A047451 (n mod 8 = {0,6}), and those containing neither 0's nor 2's is A004767 (n mod 8 = {3,7}).
(End)

Examples

			Triangle begins:
   0;
   1,  2;
   3,  0,  1;
   2,  4,  3,  5;
   5,  1,  0,  2,  3;
   4,  3,  5,  1,  6,  7;
   6,  7,  2,  0,  5,  4,  8;
   8,  5,  9,  4,  7,  2, 10,  6;
   7, 10,  8,  3,  0,  6,  9,  5,  4;
  11,  6, 12,  7,  1,  8,  3, 10,  9, 13;
   9,  8,  4, 11,  2,  0,  1, 12,  6,  7, 10;
  10, 11,  7, 12,  4,  3,  2,  9,  8, 14, 13, 15;
  12,  9, 10,  6,  8,  1,  0, 11,  7,  4, 16, 14, 17;
  ...
From _Omar E. Pol_, Jun 07 2017: (Start)
The triangle may be reformatted as an isosceles triangle so that the zero sequence (A000004) appears in the central column (but note that this is NOT the way the triangle is constructed!):
.
.                    0;
.                  1,  2;
.                3,  0,  1;
.              2,  4,  3,  5;
.            5,  1,  0,  2,  3;
.          4,  3,  5,  1,  6,  7;
.        6,  7,  2,  0,  5,  4,  8;
.     8,   5,  9,  4,  7,  2, 10,  6;
.   7,  10,  8,  3,  0,  6,  9,  5,  4;
...
(End)
		

Crossrefs

Cf. A000004 (middle diagonal).
Cf. A046092 (indices of the zeros).
Every diagonal and every column of the right triangle is a permutation of A001477.
The left and right edges of the right triangle give A286294 and A286295.
Cf. A274651 is the same triangle but with 1 added to every entry.
Other sequences of the same family are A269526, A274528, A274820, A274821, A286297, A288530, A288531.
Sequences mentioned in N. J. A. Sloane's proof are A000170, A274616 and A287864.
Cf. A288384.
See A308179, A308180 for a very similar triangle.

Programs

  • Mathematica
    (* function a274651[] is defined in A274651 *)
    (* computation of rows 0 ... n-1 *)
    a274650[n_] := a274651[n]-1
    Flatten[a274650[13]] (* data *)
    TableForm[a274650[13]] (* triangle *)
    (* Hartmut F. W. Hoft, Jun 12 2017 *)
  • PARI
    See Links section.

Formula

T(n,k) = A274651(n+1,k+1) - 1.

A274651 Triangle read by rows: T(n,k), (1<=k<=n), in which each term is the least positive integer such that no row, column, diagonal, or antidiagonal contains a repeated term.

Original entry on oeis.org

1, 2, 3, 4, 1, 2, 3, 5, 4, 6, 6, 2, 1, 3, 4, 5, 4, 6, 2, 7, 8, 7, 8, 3, 1, 6, 5, 9, 9, 6, 10, 5, 8, 3, 11, 7, 8, 11, 9, 4, 1, 7, 10, 6, 5, 12, 7, 13, 8, 2, 9, 4, 11, 10, 14, 10, 9, 5, 12, 3, 1, 2, 13, 7, 8, 11, 11, 12, 8, 13, 5, 4, 3, 10, 9, 15, 14, 16, 13, 10, 11, 7, 9, 2, 1, 12, 8, 5, 17, 15, 18
Offset: 1

Views

Author

Omar E. Pol, Jul 02 2016

Keywords

Comments

Analog of A269526, but note that this is a right triangle.
The same rule applied to an equilateral triangle gives A269526.
We construct the triangle by reading from left to right in each row, starting with T(1,1) = 1.
Presumably every diagonal and every column is also a permutation of the positive integers, but the proof does not seem so straightforward. Of course, neither the rows nor the antidiagonals are permutations of the positive integers, since they are finite in length.
Omar E. Pol's conjecture that every column and every diagonal of the triangle is a permutation of the positive integers is true: see the link in A274650 (duplicated below). - N. J. A. Sloane, Jun 07 2017
It appears that the numbers generally appear for the first time in or near the right border of the triangle.
Theorem 1: the middle diagonal gives A000012 (the all 1's sequence).
Theorem 2: all 1's are in the middle diagonal.
For the proofs of the theorems 1 and 2 see the proofs of the theorems 1 and 2 of A274650 since both sequences are essentially the same.
From Bob Selcoe, Feb 15 2017: (Start)
The columns and diagonal are permutations of the natural numbers. The proofs are essentially the same as the proofs given for the columns and rows (respectively) in A269526.
All coefficients j <= 4 eventually populate in a repeating pattern toward the "middle diagonal" (i.e., relatively near the 1's); this is because we can build the triangle by j in ascending order; that is, we can start by placing all the 1's in the proper cells, then add the 2's, 3's, 4's, 5's, etc. So for i >= 0: since the 1's appear at T(1+2i, 1+i), the 2's appear at T(2+8i, 1+4i), T(3+8i, 3+4i), T(5+8i, 2+4i) and T(6+8i, 4+4i). Accordingly, after the first five 3's appear (at T(2,2), T(4,1), T(5,4), T(7,3) and T(8,6)), the remaining 3's appear at T(11+8i, 5+4i), T(12+8i, 7+4i), T(16+8i, 8+4i) and T(17+8i, 10+4i). Similarly for 4's, after the first 21 appearances, 4's appear at T(44+8i, 21+4i), T(45+8i, 24+4i), T(47+8i, 23+4i) and T(48+8i, 26+4i). So starting at T(41,21), this 16-coefficient pattern repeats at T(41+8i, 21+4i):
n/k 21 22 23 24 25 26
41 1 3
42 2
43 3 1 2
44 4 3
45 2 1 4
46 2
47 4 1
48 3 4
where the next 1 appears at T(49,25), and the pattern repeats at that point from the top left (so T(49,26) = 3, T(50,25) = 2, etc.).
Conjecture: as n gets sufficiently large, all coefficients j>4 will appear in a repeating pattern, populating all rows and diagonals around smaller j's near the "middle diagonal" (while I can offer no formal proof, it appears very likely that this is the case). (End)
From Hartmut F. W. Hoft, Jun 12 2017: (Start)
T(2k+1,k+1) = 1, for all k>=0, and T(n,{n/2,(n+3)/2,(n-1)/2,(n+2)/2}) = 2, for all n>=1 with mod(n,8) = {2,3,5,6} respectively, and no 1's or 2's occur in other positions.
Proof by (recursive) picture:
Positions in the triangle that are empty and those containing the dots of the guiding diagonals contain numbers larger than two.
n\k 1 2 3 4 5 6 7 8 10 12 14 16 18 20 22 24
1 |1
2 |2 .
3 | 1 2
4 | .
5 | 2 1 .
6 | 2 .
7 | 1 .
9 | |1 .
10 | |2 . .
11 | | 1 2 .
12 | | . .
13 | | 2 1 . .
14 | | 2 . .
15 | | 1 . .
16 |_____|______________._____.
17 | | |1 . .
18 | | |2 . . .
19 | | | 1 2 . .
20 | | | . . .
21 | | | 2 1 . . .
22 | | | 2 . . .
23 | | | 1 . . .
24 |_____|_______|____._______._____._______.
1 2 3 4 5 6 7 8 12 16 20 24
Consider the center of the triangle. In each octave of rows the columns in the first central quatrain contain a 1 and a 2, and the diagonals in the second central quatrain contain a 1 and a 2. Therefore, no 1's or 2's can occur in the respective downward quatrains of leading columns and trailing diagonals.
The sequence of rows containing 2's is A047447 (n mod 8 = {2,3,5,6}), those containing only 2's is A016825 (n mod 8 = {2,6}), those containing both 1's and 2's is A047621 (n mod 8 = {3,5}), those containing only 1's is A047522 (n mod 8 = {1,7}), and those containing neither 1's nor 2's is A008586 (n mod 8 = {0,4}).
(End)

Examples

			Triangle begins:
   1;
   2,  3;
   4,  1,  2;
   3,  5,  4,  6;
   6,  2,  1,  3,  4;
   5,  4,  6,  2,  7,  8;
   7,  8,  3,  1,  6,  5,  9;
   9,  6, 10,  5,  8,  3, 11,  7;
   8, 11,  9,  4,  1,  7, 10,  6,  5;
  12,  7, 13,  8,  2,  9,  4, 11, 10, 14;
  10,  9,  5, 12,  3,  1,  2, 13,  7,  8, 11;
  11, 12,  8, 13,  5,  4,  3, 10,  9, 15, 14, 16;
  13, 10, 11,  7,  9,  2,  1, 12,  8,  5, 17, 15, 18;
  ...
From _Omar E. Pol_, Jun 07 2017: (Start)
The triangle may be reformatted as an isosceles triangle so that the all 1's sequence (A000012) appears in the central column (but note that this is NOT the way the triangle is constructed!):
.
.                  1;
.                2,  3;
.              4,  1,  2;
.            3,  5,  4,  6;
.          6,  2,  1,  3,  4;
.        5,  4,  6,  2,  7,  8;
.      7,  8,  3,  1,  6,  5,  9;
.    9,  6, 10,  5,  8,  3, 11,  7;
.  8, 11,  9,  4,  1,  7, 10,  6,  5;
...
(End)
		

Crossrefs

Cf. A001844 (indices of the 1's).
Cf. A000012 (middle diagonal).
Every diagonal and every column of the right triangle is a permutation of A000027.
Cf. A274650 is the same triangle but with every entry minus 1.
Other sequences of the same family are A269526, A274528, A274820, A274821, A286297, A288530, A288531.
Sequences mentioned in N. J. A. Sloane's proof are A000170, A274616 and A287864.

Programs

  • Mathematica
    f[1,1] = 1; (* for 1 < n and 1 <= k <= n *)
    f[n_,k_] := f[n,k] = Module[{vals=Sort[Join[Map[f[n, #]&, Range[1, k-1]], Map[f[#, k]&, Range[k, n-1]], Map[f[n-k+#, #]&, Range[1, k-1]], Map[f[n-#, k+#]&, Range[1, Floor[(n-k)/2]]]]], c}, c=Complement[Range[1, Last[vals]], vals]; If[c=={}, Last[vals]+1, First[c]]]
    (* computation of rows 1 ... n of triangle *)
    a274651[n_] := Prepend[Table[f[i, j], {i, 2, n}, {j, 1, i}], {1}]
    Flatten[a274651[13]] (* data *)
    TableForm[a274651[13]] (* triangle *)
    (* Hartmut F. W. Hoft, Jun 12 2017 *)

Formula

T(n,k) = A274650(n-1,k-1) + 1.

A287864 Consider a symmetric pyramid-shaped chessboard with rows of squares of lengths n, n-2, n-4, ..., ending with either 2 or 1 squares; a(n) is the maximal number of mutually non-attacking queens that can be placed on this board.

Original entry on oeis.org

1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23
Offset: 1

Views

Author

N. J. A. Sloane, Jun 03 2017

Keywords

Comments

Since there can be at most one queen per row, for n >= 2, a(n) <= floor(n/2). It would be nice to know how fast this sequence grows. Compare A287867.
If n=2t, the board contains t(t+1) squares; if n=2t+1 it contains (t+1)^2 squares. The number of squares is thus given by the quarter-squares sequence (A002620(n+1)).
The bisection a(2n+1) is A274933. - Rob Pratt, Jun 04 2017
For n = 1 to 100, here are the exceptions to the pattern that the values increase by 1 every two steps:
a(1) = a(2) = a(3) = 1
a(12) = a(13) = a(14) = 6
a(27) = a(28) = a(29) = 13
a(44) = a(45) = a(46) = 21
a(59) = a(60) = a(61) = 28
a(74) = a(75) = a(76) = 35
a(89) = a(90) = a(91) = 42. - Rob Pratt, Jun 04 2017

Examples

			Q = queen, X = empty square
---
Q   a(1)=1
---
QX   a(2)=1
---
.X.
QXX   a(3)=1
---
.QX.
XXXQ   a(4)=2
----
..X..
.QXX.
XXXQX   a(5)=2
-----
..QX..
.XXXQ.
XQXXXX   a(6)=3
------
...X...
..QXX..
.XXXQX.
XQXXXXX   a(7)=3
-------
...QX...
..XXXQ..
.XQXXXX.
XXXXQXXX   a(8)=4
--------
....QX....
...XXXQ...
..XQXXXX..
.XXXXQXXX.
XXQXXXXXXX   a(10)=5
----------
.....QX.....
....XXXQ....
...XQXXXX...
..XXXXQXXX..
.XXQXXXXXXX.
XXXXXXXXXQXX   a(12)=6
------------
......QX......
.....XXXQ.....
....XQXXXX....
...XXXXQXXX...
..XXQXXXXXXX..
.XXXXXXXXXQXX.
XXXXXXXXXXXXXX   a(14)=6
--------------
		

Crossrefs

Extensions

a(15)-a(100) from Rob Pratt, Jun 04 2017

A274933 Maximal number of non-attacking queens on a quarter chessboard containing n^2 squares.

Original entry on oeis.org

1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 62
Offset: 1

Views

Author

N. J. A. Sloane, Jul 13 2016

Keywords

Comments

Take the quarter-board formed from a 2n-1 X 2n-1 chessboard by joining the center square to the top two corners. There are n^2 squares. If n = 11, 2n-1 = 21 and the board looks like this, with 11^2 = 121 squares (the top row is the top of the chessboard, the single cell at the bottom is at the center of the board):
OOOOOOOOOOOOOOOOOOOOO
-OOOOOOOOOOOOOOOOOOO-
--OOOOOOOOOOOOOOOOO--
---OOOOOOOOOOOOOOO---
----OOOOOOOOOOOOO----
-----OOOOOOOOOOO-----
------OOOOOOOOO------
-------OOOOOOO-------
--------OOOOO--------
---------OOO---------
----------O----------
The main question is, how does a(n) behave when n is large? (See A287866.)
This is a bisection of A287864. - Rob Pratt, Jun 04 2017

Examples

			For n=6 the maximal number is 5:
OOXOOOOOOOO
-OOOOOOXOO-
--OXOOOOO--
---OOOXO---
----OOO----
-----X-----
Examples from _Rob Pratt_, Jul 13 2016:
(i) For n=15 the maximal number is 13:
OOOOOOXOOOOOOOOOOOOOOOOOOOOOO
-OOOOOOOOOOOOOOOOOOXOOOOOOOO-
--OOOOOXOOOOOOOOOOOOOOOOOOO--
---OOOOOOOOOOOOOOOXOOOOOOO---
----OOOOOOOOOOOXOOOOOOOOO----
-----OOOOOOOXOOOOOOOOOOO-----
------OOOXOOOOOOOOOOOOO------
-------OOOOOOOOOXOOOOO-------
--------OOXOOOOOOOOOO--------
---------OOOOOOOOXOO---------
----------OOOOXOOOO----------
-----------XOOOOOO-----------
------------OXOOO------------
-------------OOO-------------
--------------O--------------
(ii) For n=31 the maximal number is 28:
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOO
-OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOO-
--OOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO--
---OOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO---
----OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOO----
-----OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOO-----
------OOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO------
-------OOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO-------
--------OOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOOO--------
---------OOOOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOO---------
----------OOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOOO----------
-----------OOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOOOOO-----------
------------OOOOOOOOOOOOOOOOOOOOOOOOOOOXOOOOOOOOO------------
-------------OOOOOOOOOOOOOOOOOOXOOOOOOOOOOOOOOOO-------------
--------------OOOOOOOOOOXOOOOOOOOOOOOOOOOOOOOOO--------------
---------------OOOOOXOOOOOOOOOOOOOOOOOOOOOOOOO---------------
----------------OOOOOOOXOOOOOOOOOOOOOOOOOOOOO----------------
-----------------OOOOOOOOOOOOOOOOOOOXOOOOOOO-----------------
------------------OOOOXOOOOOOOOOOOOOOOOOOOO------------------
-------------------OOOOOOOOOOOOOOOOXOOOOOO-------------------
--------------------OXOOOOOOOOOOOOOOOOOOO--------------------
---------------------OOOOOOOOOOOOOXOOOOO---------------------
----------------------OOOOOOOOXOOOOOOOO----------------------
-----------------------OOOXOOOOOOOOOOO-----------------------
------------------------OOOOOOOOOXOOO------------------------
-------------------------XOOOOOOOOOO-------------------------
--------------------------OOOOOOXOO--------------------------
---------------------------OOXOOOO---------------------------
----------------------------OOOOO----------------------------
-----------------------------OOO-----------------------------
------------------------------O------------------------------
		

Crossrefs

Formula

Since there can be at most one queen per row, a(n) <= n. In fact, since there cannot be a queen on both rows 1 and 2, a(n) <= n-1 for n>1. - N. J. A. Sloane, Jun 04 2017

Extensions

Terms a(n) with n >= 15 corrected and extended by Rob Pratt, Jul 13 2016
a(46)-a(67) from Andy Huchala, Mar 27 2024

A352241 Maximal number of nonattacking black-square queens on an n X n chessboard.

Original entry on oeis.org

1, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 13, 14, 15, 16, 17, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 33, 34, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 45, 46, 47
Offset: 1

Views

Author

George Baloglou, Mar 09 2022

Keywords

Crossrefs

Cf. this sequence (maximal number for black-squares), A352325 (black-squares counts), A352426 (maximal number for white-squares), A352599 (white-squares counts).

Formula

Conjecture: a(5k)=4k-1, a(5k+1)=4k, a(5k+2)=4k+1, a(5k+3)=4k+1, a(5k+4)=4k+2. [This does not hold for n = 52 and n = 57. - Andy Huchala, Apr 02 2024]
a(n) = A053757(n-1), at least for 1 <= n <= 12. [This is unlikely to continue. - N. J. A. Sloane, Mar 11 2022] [Indeed the equality does not hold for n=13. - Martin Ehrenstein, Mar 11 2022]
a(n+1) >= a(n); a(2n) = A352426(2n). - Martin Ehrenstein, Mar 23 2022

Extensions

a(13)-a(26) from Martin Ehrenstein, Mar 11 2022
a(27)-a(28) from Martin Ehrenstein, Mar 15 2022
a(29)-a(30) from Martin Ehrenstein, Mar 23 2022
a(31)-a(60) from Andy Huchala, Mar 27 2024

A352426 Maximal number of nonattacking white-square queens on an n X n chessboard.

Original entry on oeis.org

0, 1, 1, 2, 4, 4, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 21, 22, 23, 24, 25, 26, 26, 27, 28, 29, 29, 30, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 45, 46, 47, 48, 48, 49, 50, 51, 51, 52, 53
Offset: 1

Views

Author

Martin Ehrenstein, Mar 16 2022

Keywords

Comments

Equivalently the maximal number of nonattacking black-square queens on an inverted n X n chessboard, that is a board with the a1 square white, the a2 and b1 squares black, etc.

Crossrefs

Programs

  • Python
    def fill(rows, queens, leftattack, notdownattack, rightattack, color):
        global c
        available = ~leftattack & notdownattack & ~rightattack & color
        if rows==1:
            if available==0:
                c[queens] = c.get(queens, 0) + 1
            else:
                c[queens+1] = c.get(queens+1, 0) + bin(available).count('1')
            return
        while available:
            attack = available & -available
            fill(rows-1, queens+1, (leftattack|attack)<<1, notdownattack&~attack, (rightattack|attack)>>1, ~color)
            available &= available - 1
        fill(rows-1, queens, leftattack<<1, notdownattack, rightattack>>1, ~color)
    print(' n a(n)    count')
    for n in range(1, 32):
        c=dict()
        fill(n, 0, 0, (1<
    				

Formula

a(2n) = A352241(2n).

Extensions

a(17)-a(24) from Vaclav Kotesovec, Mar 17 2022
a(25)-a(26) from Vaclav Kotesovec, Mar 20 2022
a(27) onwards from Andy Huchala, Mar 27 2024

A359032 a(n) is the number of ways to place non-attacking queens on an n X n board with no queens above the main diagonal.

Original entry on oeis.org

1, 2, 4, 9, 23, 66, 204, 669, 2305, 8348, 31542, 124021, 507937, 2154494, 9455972, 42847307, 200258387, 962904904, 4759773172, 24142168317, 125575232141, 668689805690, 3643481771390, 20286338601133
Offset: 0

Views

Author

Alexander Kuleshov, Dec 13 2022

Keywords

Comments

Equivalently, a(n) is the number of ways to place non-attacking queens on a right triangular board with n cells on each side.
Task was proposed by Yandex, during ICPC NERC 2022-2023, as a side CTF contest.
The terms appear to be growing exponentially.

Examples

			a(0) = 1, since there is only the empty board.
a(1) = 2, since there are 2 configurations:
  +---+  +---+
  | Q |  | . |
  +---+  +---+
a(2) = 4
  +-----+ +-----+ +-----+ +-----+
  | . # | | Q # | | . # | | . # |
  | . . | | . . | | Q . | | . Q |
  +-----+ +-----+ +-----+ +-----+
a(3) = 9
  +-------+
  | . # # |
  | . . # |
  | . . . |
  +-------+
  +-------+  +-------+
  | Q # # |  | . # # |
  | . . # |  | Q . # |
  | . . . |  | . . . |
  +-------+  +-------+
  +-------+  +-------+
  | . # # |  | . # # |
  | . . # |  | . Q # |
  | Q . . |  | . . . |
  +-------+  +-------+
  +-------+  +-------+
  | . # # |  | . # # |
  | . . # |  | . . # |
  | . Q . |  | . . Q |
  +-------+  +-------+
  +-------+  +-------+
  | Q # # |  | . # # |
  | . . # |  | Q . # |
  | . Q . |  | . . Q |
  +-------+  +-------+
		

Crossrefs

Programs

  • Python
    bitToIndex = {}
    indexToBit = {}
    def addToBoard(board, bit, n):
        (i, j) = bitToIndex[bit]
        for k in range(n - j):
            board |= indexToBit[(k, j)]
        for k in range(n - i):
            board |= indexToBit[(i, k)]
        for k in range(-min(i, j), (n - abs(i - j) + 1) // 2 - min(i, j)):
            board |= indexToBit[(i + k, j + k)]
        for k in range(i + j + 1):
            board |= indexToBit[(k, i + j - k)]
        return board
    def r(start, board, n):
        result = 1
        for i in range(start, n * (n + 1) // 2):
            bit = 1 << i
            if board & bit == 0:
                newBoard = addToBoard(board, bit, n)
                result += r(i + 1, newBoard, n)
        return result
    # Number of peaceful queens boards in a triangular square grid with size n
    def a(n):
        bit = 1
        for j in range(n):
            for k in range(n - j):
                bitToIndex[bit] = (j, k)
                indexToBit[(j, k)] = bit
                bit *= 2
        return r(0, 0, n)
    for n in range(21):
        print(a(n))

Extensions

a(20)-a(23) from Bert Dobbelaere, Jan 29 2023
Showing 1-8 of 8 results.