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-3 of 3 results.

A260113 Maximum number of queens on an n X n chessboard such that no queen attacks more than one other queen.

Original entry on oeis.org

1, 2, 3, 4, 5, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, 26, 28, 29, 30, 32, 33, 34, 36, 37, 38, 40
Offset: 1

Views

Author

Rob Pratt, Jul 16 2015

Keywords

Comments

Can be formulated as an integer linear programming problem as follows. Define a graph with a node for each cell and an edge for each pair of cells that are a queen's move apart. Let binary variable x[i] = 1 if a queen appears at node i, and 0 otherwise. The objective is to maximize sum x[i]. Let N[i] be the set of neighbors of node i. To enforce the rule that x[i] = 1 implies sum {j in N[i]} x[j] <= 1, impose the linear constraint sum {j in N[i]} x[j] - 1 <= (|N[i]| - 1) * (1 - x[i]) for each i.
An alternative formulation uses constraints x[i] + x[j] + x[k] <= 2 for each forbidden triple of nodes.
Taking into account known values, it is reasonable to conjecture that a(n) = floor(4*n/3) for n > 5. - Giovanni Resta, Aug 07 2015.
a(n) = floor(4*n/3) for large n. - Géza Makay, Dec 13 2024

Examples

			a(8) = 10:
  X-------
  ----XX--
  -X------
  -X------
  ------X-
  ------X-
  --XX----
  X-------
		

Crossrefs

A260090 is the corresponding sequence for kings.
Cf. A004773 (after Resta).

Formula

Ponder This solution page shows a(6n) = 8n.

Extensions

a(16)-a(30) from Giovanni Resta, Aug 07 2015

A381749 Triangle read by rows: T(n,k), n >= k, is the maximum number of kings on a n X k chessboard so that no king attacks more than one other king.

Original entry on oeis.org

1, 2, 2, 2, 4, 4, 3, 4, 6, 8, 4, 6, 8, 10, 12, 4, 6, 8, 11, 14, 16, 5, 8, 10, 13, 16, 18, 21, 6, 8, 12, 14, 18, 20, 24, 26, 6, 10, 12, 16, 20, 22, 26, 30, 33, 7, 10, 14, 18, 22, 25, 29, 32, 36, 40, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 8, 12, 16, 21, 26
Offset: 1

Views

Author

Yifan Xie, Mar 06 2025

Keywords

Comments

Two kings attack each other if their corresponding cells have a common point.
Define a graph G = (V,E), where V is the set of kings and E includes all pairs of attacking kings. Then the constraint is equivalent to all connected components of G having 1 or 2 kings. Denote the connected components of G by blocks.
Extend the board P to P' by adding a row at the bottom and a column at the right. Define the neighborhood of a block B as the union of the 2 X 2 squares whose upper-left corner is a cell in B.
The neighborhoods of permitted blocks are shown, with B marked by 'X' and the remaining part of B's neighborhood by '-':
X- XX- X- X-- X-
--; ---; X- -X- X--
--; ---; -- .
Suppose that a cell C is in the neighborhoods of two distinct blocks B1 and B2. Then B1 and B2 both have a cell in the 2 X 2 square whose lower-right corner is C, but these two cells must be neighbor to each other, a contradiction.
Therefore, the neighborhoods of all blocks in P are non-overlapping in P'. Note that the size of a block's neighborhood is at least three times the size of the block. That is, T(n,k) <= (n+1)*(k+1)/3.
Also, note that 2 X 6 and 3 X 6 boards can be tiled with 6-sized neighborhoods, so m X 6 boards, where m > 1, can also be tiled with 6-sized neighborhoods. Therefore, the remaining details are not tedious to work with since a n X k board can generally be reduced to a (n mod 6) X (k mod 6) board.

Examples

			The triangle begins:
  n\k [1] [2]  [3]  [4]  [5]  [6]  [7]
  [1]  1;
  [2]  2,  2;
  [3]  2,  4,   4;
  [4]  3,  4,   6,   8;
  [5]  4,  6,   8,  10,  12;
  [6]  4,  6,   8,  11,  14,  16;
  [7]  5,  8,  10,  13,  16,  18,  21;
  ...
T(9,9) = 33:
  XX-XX-X-X
  ------X-X
  XX-XX----
  ------X-X
  X-X-X-X-X
  X-X------
  ----XX-XX
  X-X------
  X-X-XX-XX
		

Crossrefs

A260090 gives the main diagonal.

Programs

  • PARI
    T(n,k) = floor((n+1)*(k+1)/3) - if((n+1)*(k+1) % 6 == 3, 1, 0) - if(k == 3 && n % 3 == 0, 1, 0) - if(k == 6 && n % 6 == 3, 1, 0);

Formula

T(3*m,3) = 4*m;
T(6*m+3,6) = 14*m+8;
For k != 3 or 6, T(n,k) = floor((n+1)*(k+1)/3) - [(n+1)*(k+1) (mod 6) == 3] where [] denotes the Iverson bracket.

A379636 Triangle read by rows: T(n,k) (n >= k) is the maximum number of black cells in a n X k grid such that no black cell is edge-adjacent to more than one black cell.

Original entry on oeis.org

1, 2, 2, 2, 4, 5, 3, 4, 7, 8, 4, 6, 9, 11, 14, 4, 6, 10, 12, 16, 18, 5, 8, 12, 15, 19, 22, 26, 6, 8, 14, 16, 22, 24, 30, 32, 6, 10, 15, 19, 24, 28, 33, 38, 42, 7, 10, 17, 20, 27, 30, 37, 40, 47, 50, 8, 12, 19, 23, 30, 34, 41, 46, 52, 57, 63, 8, 12, 20, 24, 32
Offset: 1

Views

Author

Yifan Xie, Mar 12 2025

Keywords

Comments

Two cells are edge-adjacent if they have a common edge.
T(n,1) and the upper bound are shown by blackening the left two cells in each three consecutive cells (refer to T(8,1) example).
If both n and k are even, T(n,k) is reached by checkerboard coloring. The upper bound follows from T(2,2) = 2.
Suppose that k is odd. T(n,k) can be constructed by applying the T(n,1) construction on each odd-numbered row, and the coloring of even-numbered rows opposite to odd-numbered ones (refer to T(7,7) example). If n is even, the upper bound follows from T(n,k) <= T(n,k-1) + T(n,1).
If n is odd, we choose an up-and-right path visiting cells a_1, a_2, ..., a_(n+k-1) in that order. Set a_1 as the lower-left corner and a_(n+k-1) as the upper-right corner. The edge a_(2i) - a_(2i+1) continues the previous direction. If a_(2i+1) is not on the upper edge or on the right edge, choose a_(2i+2) such that a_(2i+1) and a_(2i+2) are not both black; Suppose the contrary, and then a_(2i+1) and its upper and right neighbors are all black, a contradiction.
Therefore we divide the grid into the upper-left and lower-right parts, each of which can be divided into 2 X 2 grids, so there are at most (n-1)*(k-1)/2 black cells. As for the path, the part not on the upper edge or on the right edge has no more than half black cells, while the edge part contains at most n cells, hence T(n,k) <= (n-1)*(k-1)/2 + (k-1)/2 + T(n,1) = n*(k-1)/2 + ceiling(2*n/3).
The following example illustrates the colored grid and the corresponding path:
XX_XX_XX_ ......XX_
X_XX_XX ....X_X..
X_X__X__X ...._....
X_X_X_XX_ X_X_X....
__X_X__X ........
XX_X_X_X_ X........

Examples

			The triangle begins:
  n\k [1] [2]  [3]  [4]  [5]  [6]  [7]
  [1]  1;
  [2]  2,  2;
  [3]  2,  4,   5;
  [4]  3,  4,   7,   8;
  [5]  4,  6,   9,  11,  14;
  [6]  4,  6,  10,  12,  16,  18;
  [7]  5,  8,  12,  15,  19,  22,  26;
  ...
T(8,1) = 6:
  XX_XX_XX
T(7,7) = 26:
  XX_X_XX
  __X_X__
  XX_X_XX
  --X_X__
  XX_X_XX
  __X_X__
  XX_X_XX
		

Crossrefs

Cf. A260090 (where adjacency is defined by having a common vertex)

Programs

  • PARI
    T(n,k)=if(n%2==0 && k%2==0, n*k/2, if(n%2==0, n*(k-1)/2+ceil(2*n/3), if(k%2==0, k*(n-1)/2+ceil(2*k/3), n*(k-1)/2+ceil(2*n/3))));

Formula

If n and k are both even, T(n,k) = n*k/2;
If n is even and k is odd, T(n,k) = n*(k-1)/2 + ceiling(2*n/3);
If n is odd and k is even, T(n,k) = k*(n-1)/2 + ceil(2*k/3);
If n and k are both odd, T(n,k) = n*(k-1)/2 + ceiling(2*n/3).
Showing 1-3 of 3 results.