login
Minesweeper sequence of positive integers arranged on a 2D grid along a square maze.
7

%I #21 Mar 20 2020 23:37:32

%S 2,-1,-1,3,-1,3,-1,4,3,1,-1,4,-1,3,4,2,-1,2,-1,2,3,3,-1,2,1,0,2,3,-1,

%T 2,-1,2,2,1,3,2,-1,1,1,2,-1,4,-1,2,3,3,-1,1,0,0,2,3,-1,1,1,1,3,3,-1,3,

%U -1,2,2,1,0,1,-1,3,3,2,-1,2,-1,2,1,0,1,2,-1,2,1

%N Minesweeper sequence of positive integers arranged on a 2D grid along a square maze.

%C Place positive integers on 2D grid starting with 1 in the top left corner and continue along the square maze as in A081344.

%C Replace each prime with -1 and each nonprime with the number of primes in adjacent grid cells around it.

%C n is replaced by a(n).

%C This sequence treats prime numbers as "mines" and fills gaps according to the rules of the classic Minesweeper game.

%C a(n) < 5.

%C Set of n such that a(n) = 4 is unbounded (conjectured).

%H Michael De Vlieger, <a href="/A326408/b326408.txt">Table of n, a(n) for n = 1..10000</a>

%H Michael De Vlieger, <a href="/A326408/a326408.png">Minesweeper-style graph</a> read along original mapping, replacing -1 with a "mine", and 0 with blank space.

%H Michael De Vlieger, <a href="/A326408/a326408_1.png">Square plot of a million terms</a> read along original mapping, with black indicating a prime and levels of gray commensurate to a(n).

%H Witold Tatkiewicz, <a href="https://pastebin.com/dWGN3SrE">link for Java program</a>

%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Minesweeper_(video_game)">Minesweeper game</a>

%e Consider positive integers distributed onto the plane along increasing square array:

%e 1 4 5 16 17 36 ...

%e 2 3 6 15 18 35

%e 9 8 7 14 19 34

%e 10 11 12 13 20 33

%e 25 24 23 22 21 32

%e 26 27 28 29 30 31

%e ...

%e 1 is not prime and in adjacent grid cells there are 2 primes: 2 and 3. Therefore a(1) = 2.

%e 2 is prime, therefore a(2) = -1.

%e 8 is not prime and in adjacent grid cells there are 4 primes: 2, 3, 7 and 11. Therefore a(8) = 4.

%e Replacing n with a(n) in the plane described above, and using "." for a(n) = 0 and "*" for negative a(n), we produce a graph resembling Minesweeper, where the mines are situated at prime n:

%e 2 3 * 2 * 2 * 1 . 1 * 1 ...

%e * * 3 4 2 3 1 2 1 3 2 2

%e 3 4 * 3 * 1 1 2 * 3 * 1

%e 1 * 4 * 2 2 2 * 3 * 2 2

%e 1 2 * 3 3 2 * 3 3 1 2 2

%e . 2 3 * 2 * 4 * 2 2 2 *

%e . 1 * 3 3 2 * 3 * 2 * 4

%e . 2 3 * 1 1 1 3 2 4 3 *

%e 1 2 * 2 1 . 1 2 * 2 * 2

%e 1 * 2 1 . . 1 * 3 3 1 1

%e 1 1 1 . 1 1 2 2 * 2 1 .

%e . 1 1 1 1 * 2 2 2 * 1 1

%e ...

%e In order to produce the sequence, the graph is read along its original mapping.

%t Block[{n = 9, s}, s = ArrayPad[Array[If[#1 < 2 #2 - 1, #2^2 + #2 - #1, (#1 - #2)^2 + #2] & @@ {#1 + #2 - 1, #2} & @@ If[Or[And[#2 < #1, EvenQ@ #1], And[#1 < #2, EvenQ@ #2]], {#1, #2}, {#2, #1}] &, {# + 1, # + 1}], 1] &@ n; Table[If[PrimeQ@ m, -1, Count[#, _?PrimeQ] &@ Union@ Map[s[[#1, #2]] & @@ # &, Join @@ Array[FirstPosition[s, m] + {##} - 2 &, {3, 3}]]], {m, n^2}] (* _Michael De Vlieger_, Oct 04 2019 *)

%o (Java) See Links section.

%Y Cf. A081344 - plane mapping

%Y Different arrangements of integers:

%Y Cf. A326405 - antidiagonals,

%Y Cf. A326406 - triangle maze,

%Y Cf. A326407 - square mapping,

%Y Cf. A326409 - Hamiltonian path,

%Y Cf. A326410 - Ulam's spiral.

%K sign,tabl

%O 1,1

%A _Witold Tatkiewicz_, Oct 04 2019