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.

A327893 Minesweeper sequence of positive integers arranged in a hexagonal spiral.

This page as a plain text file.
%I A327893 #58 Feb 28 2020 01:45:02
%S A327893 4,-1,-1,3,-1,3,-1,3,2,4,-1,3,-1,3,2,2,-1,3,-1,2,0,2,-1,3,1,2,2,2,-1,
%T A327893 2,-1,1,1,1,2,3,-1,2,0,1,-1,4,-1,1,1,2,-1,1,0,1,2,3,-1,3,1,0,0,1,-1,4,
%U A327893 -1,1,0,0,1,3,-1,2,2,2,-1,2,-1,3,1,1,0,1,-1,3
%N A327893 Minesweeper sequence of positive integers arranged in a hexagonal spiral.
%C A327893 Place positive integers on a 2D grid starting with 1 in the center and continue along a hexagonal spiral. Replace each prime with -1 and each nonprime with the number of primes in adjacent grid cells around it. n is replaced by a(n). This sequence treats prime numbers as "mines" and fills gaps according to the rules of the classic Minesweeper game.
%C A327893 The largest term in the sequence is 4 since 1 is surrounded by 3 odd numbers {3, 5, 7} and the only even prime. Additionally, the pattern of odd and even numbers appears in alternating rows oriented in a triangular symmetry such that no other number has more than four odd numbers. (This courtesy of _Witold Tatkiewicz_.)
%H A327893 Michael De Vlieger, <a href="/A327893/b327893.txt">Table of n, a(n) for n = 1..10621</a> (60 concentric hexagons).
%H A327893 Michael De Vlieger, <a href="/A327893/a327893.png">Minesweeper style hexagonal plot of 1261 terms</a>, replacing -1 with n in a black circle, and 0 represented by blank space.
%H A327893 Michael De Vlieger, <a href="/A327893/a327893_1.png">Hexagonal plot of 30301 terms</a>, (100 concentric hexagons), color coded.
%H A327893 Michael De Vlieger, <a href="/A327893/a327893_2.png">Hexagonal plot of 120601 terms</a>, (200 concentric hexagons), color coded.
%H A327893 Michael De Vlieger, <a href="/A327893/a327893_3.png">Plot of 469 terms</a>, with 12 concentric hexagons smoothed into concentric rings, color coded.
%H A327893 Michael De Vlieger, <a href="/A327893/a327893_4.png">Plot of 120601 terms</a>, with 200 concentric hexagons smoothed into concentric rings, color coded.
%e A327893 Consider a spiral grid drawn counterclockwise with the largest number k = A003219(n) = 3*n*(n+1)+1 in "shell" n, and each shell has A008458(n) elements:
%e A327893           28--27--26--25
%e A327893           /             \
%e A327893         29  13--12--11  24
%e A327893         /   /         \   \
%e A327893       30  14   4---3  10  23
%e A327893       /   /   /     \   \   \
%e A327893     31  15   5   1---2   9  22
%e A327893       \   \   \         /   /
%e A327893       32  16   6---7---8  21
%e A327893         \   \             /
%e A327893         33  17--18--19--20  ...
%e A327893           \                /
%e A327893           34--35--36--37--38
%e A327893 1 is not prime and in the 6 adjacent cells 2 through 7 inclusive, we have 4 primes, therefore a(1) = 4.
%e A327893 2 is prime therefore a(2) = -1.
%e A327893 4 is not prime and in the 6 adjacent cells {1, 3, 12, 13, 14, 5} there are 4 primes, therefore a(4) = 4, etc.
%e A327893 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 A327893          2---2---2---1
%e A327893         /             \
%e A327893        *   *---3---*   3
%e A327893       /   /         \   \
%e A327893      2   3   3---*   4   *
%e A327893     /   /   /     \   \   \
%e A327893    *   2   *   4---*   2   2
%e A327893     \   \   \         /   /
%e A327893      1   3   3---*---3   .
%e A327893       \   \             /
%e A327893        1   *---3---*---2  ...
%e A327893         \                 /
%e A327893          1---2---3---*---2
%t A327893 Block[{n = 6, m, s, t, u}, m = n + 1; s = Array[3 #1 (#1 - 1) + 1 + #2 #1 + #3 & @@ {#3, #4, Which[Mod[#4, 3] == 0, Abs[#1], Mod[#4, 3] == 1, Abs[#2], True, Abs[#2] - Abs[#1]]} & @@ {#1, #2, If[UnsameQ @@ Sign[{#1, #2}], Abs[#1] + Abs[#2], Max[Abs[{#1, #2}]]], Which[And[#1 > 0, #2 <= 0], 0, And[#1 >= #2, #1 + #2 > 0], 1, And[#2 > #1, #1 >= 0], 2, And[#1 < 0, #2 >= 0], 3, And[#1 <= #2, #1 + #2 < 0], 4, And[#1 > #2, #1 + #2 <= 0], 5, True, 0]} & @@ {#2 - m - 1, m - #1 + 1} &, {#, #}] &[2 m + 1]; t = s /. k_ /; k > 3 n (n + 1) + 1 :> -k; Table[If[PrimeQ@ m, -1, Count[#, _?PrimeQ] &@ Union@ Map[t[[#1, #2]] & @@ # &, Join @@ Array[FirstPosition[t, m] + {##} - 2 & @@ {#1, #2 + Boole[#1 == #2 == 2] + Boole[#1 == 1]} &, {3, 2}]]], {m, 3 n (n - 1) + 1}]]
%Y A327893 Cf. A003215, A008458, A326405, A326406, A326407, A326408, A326409, A326410.
%K A327893 easy,sign
%O A327893 1,1
%A A327893 _Michael De Vlieger_, Oct 09 2019