An array battle with odd secret powers

JavaScript (ES6),  83 81 80  76 bytes

The output is a space-delimited string of coordinates $x,y$.

f=(n,x=y=23,k=5,v=x*y)=>y?(v&1|~v*k%n?[]:[x,y]+' ')+f(n,--x||23|!y--,k^6):[]

Try it online!

How?

Let $c_{x,y}=xy+1$ be the value of the cell located at $(x,y)$.

Since the cells on the edge are not accounted, we assume $0<x<24$ and $0<y<24$.

$c_{x,y}$ is odd if either $x$ or $y$ is even (or both of them).

If $x$ is odd, then $c_{x-1,y}$ and $c_{x+1,y}$ are odd. But in that case, $y$ must be even, and so are $c_{x,y-1}$ and $c_{x,y+1}$. The sum of the cell and its odd surrounding neighbors is:

$$s_{x,y}=c_{x,y}+c_{x-1,y}+c_{x+1,y}=3c_{x,y}$$

Similarly, if $y$ is odd:

$$s_{x,y}=c_{x,y}+c_{x,y-1}+c_{x,y+1}=3c_{x,y}$$

If both $x$ and $y$ are even, all surrounding neighbors are odd:

$$s_{x,y}=c_{x,y}+c_{x-1,y}+c_{x+1,y}+c_{x,y-1}+c_{x,y+1}=5c_{x,y}$$

This multiplier ($3$ or $5$) is named $k$ in the JS code.

Commented

f = (                // f is a recursive function taking:
  n,                 //   n      = input
  x = y = 23,        //   (x, y) = current coordinates, starting at (23, 23)
  k = 5,             //   k      = multiplier (3 or 5)
  v = x * y          //   v      = x * y (value of the current cell - 1)
) =>                 //
  y ?                // if y is greater than 0:
    ( v & 1 |        //   if v is odd (meaning that v + 1 is not)
      ~v * k % n ?   //   or n is not a divisor of -(v + 1) * k:
        []           //     append nothing
      :              //   else:
        [x, y] + ' ' //     append the coordinates followed by a space
    ) +              //
    f(               //   append the result of a recursive call:
      n,             //     pass n unchanged
      --x ||         //     decrement x; if the result is 0:
        23 | !y--,   //       pass 23 instead and decrement y
      k ^ 6          //     update k (5 -> 3 -> 5 -> ...)
    )                //   end of recursive call
  :                  // else:
    []               //   stop recursion

C# (Visual C# Interactive Compiler), 97 93 91 90 bytes

x=>{for(int i=0,d=0,j;++i<24;d=5)for(j=0;++j<24;d^=6)if(i*j%2+(i*j+1)*d%x<1)Print((i,j));}

Saved 6 bytes thanks to @Kevin Cruijssen!

Try it online!

Python 2, 83 bytes

lambda n:[(x,y)for x in R for y in R if~(x*y)*[5,3][x+y&1]%n<1>x*y%2]
R=range(1,24)

Try it online!

Thanks to Arnauld for saving a byte.

Leave a Comment