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.

A292670 Least number of symbols required to fill a grid of size n^2 X n^2 row by row in the greedy way such that in no row or column or n X n square any symbol occurs twice.

This page as a plain text file.
%I A292670 #20 Mar 14 2025 06:22:06
%S A292670 1,6,14,26,40,53,73,114,144,161,188,210,250,279,329,482,544,577,611,
%T A292670 656,697,752,847,906,947,973,1049,1113,1210,1284,1425,1986,2112,2177,
%U A292670 2242,2326,2408,2473,2632,2748,2818,2886,3004,3125,3334,3390,3539,3661,3806,3870
%N A292670 Least number of symbols required to fill a grid of size n^2 X n^2 row by row in the greedy way such that in no row or column or n X n square any symbol occurs twice.
%C A292670 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 A292670 In contrast to the sudoku case, the n X n 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 n-1 (having up to (2n-1)^2 grid points).
%H A292670 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/MooreNeighborhood.html">Moore Neighborhood</a>.
%e A292670 For n = 2, the 4 X 4 grid is filled as follows:
%e A292670    [1 2 3 4]
%e A292670    [3 4 1 2]
%e A292670    [2 5 6 3]
%e A292670    [4 1 2 5], whence a(2) = 6.
%o A292670 (PARI) a(m,n=m^2,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^2 X n^2 board.
%o A292670 (Python)
%o A292670 def a(n):
%o A292670     s, b = n*n, n # side length, block size
%o A292670     m, S, N = 0, {1}, range(1, s+1)
%o A292670     g = [[0 for j in range(s+b)] for i in range(s+b)]
%o A292670     row, col = {i:set() for i in N}, {j:set() for j in N}
%o A292670     offsets = [(i, j) for i in range(-b+1, 1) for j in range(-b+1, 1)]
%o A292670     offsets += [(i, j) for i in range(-b+1, 0) for j in range(1, b)]
%o A292670     for i in N:
%o A292670         for j in N:
%o A292670             rect = set(g[i+o[0]][j+o[1]] for o in offsets)
%o A292670             e = min(S - row[i] - col[j] - rect)
%o A292670             g[i][j] = e
%o A292670             if e > m:
%o A292670                 m = e
%o A292670                 S.add(m+1)
%o A292670             row[i].add(e)
%o A292670             col[j].add(e)
%o A292670     return m
%o A292670 print([a(n) for n in range(1, 13)]) # _Michael S. Branicky_, Apr 13 2023
%Y A292670 Cf. A292671: grid size independent of block size; A292672, ..., A292679: A(m,n) for fixed n=2,...,9.
%K A292670 nonn
%O A292670 1,2
%A A292670 _M. F. Hasler_, Sep 20 2017
%E A292670 a(9) and beyond from _Michael S. Branicky_, Apr 13 2023