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.

A292673 Least number of symbols required to fill a grid of size n X n row by row in the greedy way such that in any row or column or rectangular 3 X 3 block no symbol occurs twice.

This page as a plain text file.
%I A292673 #15 Feb 16 2025 08:33:51
%S A292673 1,4,9,11,13,13,13,13,14,14,15,17,18,21,22,23,25,26,27,29,30,31,32,34,
%T A292673 35,38,39,40,42,45,47,49,51,53,54,55,55,55,58,59,60,61,62,63,64,65,66,
%U A292673 67,68,69,71,72,74,76,78,79,83,83,85,86,88,90,91,92,93,96
%N A292673 Least number of symbols required to fill a grid of size n X n row by row in the greedy way such that in any row or column or rectangular 3 X 3 block no symbol occurs twice.
%C A292673 Consider the symbols as positive integers. By the greedy way we mean to fill the grid row by row from left to right always with the least possible positive integer such that the three constraints (on rows, columns and rectangular blocks) are satisfied.
%C A292673 In contrast to the sudoku case, the 3 X 3 rectangles have "floating" borders, so the constraint is actually equivalent to say that any element must be different from all neighbors in a Moore neighborhood of range 2 (having up to 5*5 = 25 grid points).
%H A292673 Andrew Howroyd, <a href="/A292673/b292673.txt">Table of n, a(n) for n = 1..100</a>
%H A292673 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/MooreNeighborhood.html">Moore Neighborhood</a>
%e A292673 For n = 4, the 4 X 4 grid is filled as follows (using hexadecimal digits):
%e A292673    [1  2  3  4]
%e A292673    [4  5  6  1]
%e A292673    [7  8  9  A]
%e A292673    [2  3  B  7], whence a(4) = # { 1, ..., 9, A, B} = 11.
%e A292673 For n = 8, the grid is filled as follows:
%e A292673   [1  2  3  4  5  6  7  8]
%e A292673   [4  5  6  1  2  3  9  A]
%e A292673   [7  8  9  A  B  C  1  2]
%e A292673   [2  3  C  7  4  5  6  B]
%e A292673   [5  1  D  2  3  8  A  4]
%e A292673   [6  4  8  9  1  D  2  3]
%e A292673   [3  7  A  5  6  B  C  1]
%e A292673   [9  B  2  3  7  4  5  6], whence a(8) = # { 1, ..., 9, A, B, C, D } = 13.
%e A292673 For n = 5, 6 and 7, the solution is just the upper left n X n part of the above grid: all of these also require 13 symbols.
%o A292673 (PARI) a(n,m=3,g=matrix(n,n))={my(ok(g,k,i,j,m)=if(m,ok(g[i,],k)&&ok(g[,j],k)&&ok(concat(Vec(g[max(1,i-m+1)..i,max(1,j-m+1)..min(#g,j+m-1)])),k),!setsearch(Set(g),k))); for(i=1,n,for(j=1,n,for(k=1,n^2,ok(g,k,i,j,m)&&(g[i,j]=k)&&break)));vecmax(g)} \\ without "vecmax" the program returns the full n X n board.
%o A292673 (Python)
%o A292673 def A292673(n, b=3): # change b for A292672, ..., A292679
%o A292673     m, S, N = 0, {1}, range(1, n+1)
%o A292673     g = [[0 for j in range(n+b)] for i in range(n+b)]
%o A292673     row, col = {i:set() for i in N}, {j:set() for j in N}
%o A292673     offsets = [(i, j) for i in range(-b+1, 1) for j in range(-b+1, 1)]
%o A292673     offsets += [(i, j) for i in range(-b+1, 0) for j in range(1, b)]
%o A292673     for i in N:
%o A292673         for j in N:
%o A292673             rect = set(g[i+o[0]][j+o[1]] for o in offsets)
%o A292673             e = min(S - row[i] - col[j] - rect)
%o A292673             g[i][j] = e
%o A292673             if e > m:
%o A292673                 m = e
%o A292673                 S.add(m+1)
%o A292673             row[i].add(e)
%o A292673             col[j].add(e)
%o A292673     return m
%o A292673 print([A292673(n) for n in range(1, 101)]) # _Michael S. Branicky_, Apr 13 2023
%Y A292673 Cf. A292670, A292671, A292672, ..., A292679.
%K A292673 nonn
%O A292673 1,2
%A A292673 _M. F. Hasler_, Sep 20 2017
%E A292673 Terms a(40) and beyond from _Andrew Howroyd_, Feb 22 2020