0, 1, -1, 2, -2, 3, -3, -6, 6, 4, -4, 9, -5, -13, 5, -17, 11, 10, 8, -20, -11, 20, -9, 7, -15, -10, 17, -18, 19, -22, -8, 21, -12, 33, -31, -21, -19, 39, -7, 15, -14, 14, 12, -25, 43, -30, 25, -16, 22, 13, -34, 41, -50, 50, -28, 26, -24, -33, 46, -53, 71, -26, 18, 23, -27, -60, 54, -71, 28, -23
Offset: 0
The square spiral begins:
. .
.
11...-17...5..-13...-5 -22
| | |
10 -2....2...-1 9 19
| | | | |
8 3 0....1 -4 -18
| | | |
-20 -3...-6....6....4 17
| |
-11...20...-9....7...-15..-10
.
.
See the attached text file for a larger 31 by 31 example.
a(0) = 0. The earliest available integer.
a(1)..a(6) = 1,-1,2,-2,3,-3. These are the earliest available six numbers.
a(7) = -6. This number is fixed by previous numbers as a(0) must equal a(1) + a(3) + a(5) + a(7), therefore a(7) = 0 - 1 - 2 - 3 = -6.
a(8) = 6. The earliest available numbers when a(8) is filled are 4,-4,5,-5 but none of those can be chosen else the sequence would not be infinite. Choosing a(8) = 4 would force a(10), the number next to a(1) = 1, to equal 1 - (-1) - 0 - 4 = = -2, but -2 has already appeared. Choosing a(8) = -4 would force the number below a(7) = -6 to equal -6 - (-3) - 0 - (-4) = 1, but 1 has already appeared. Choosing a(8) = 5 would force a(10) to equal -3 which has already appeared. Note however that 5 has already been excluded as the number above a(3) = 2 must equal 2 - (-2) - (-1) - 0 = 5. Finally, choosing a(8) = -5 would force the number below a(7) to equal 2 which has already appeared. This leave 6 as the earliest available number.
a(9) = 4 as this is the earliest available number and it is not excluded by earlier numbers or by the four forced numbers already calculated around the four existing spiral edges.
a(21) = -11. Another check must be performed when choosing the earliest available number which is first seen when finding a(21). As that number is chosen the spiral is:
.
(15) 8 3
A (X) -20 -3
B * (20)
C
.
where '*' marks the position of a(21) at the lowest-left corner of the spiral, numbers surrounded by brackets are not yet in the sequence but have been fixed by earlier numbers, and 'A','B','C' are not yet fixed. When a(21) is being chosen the earliest available number is -10. If -10 is chosen for '*' then 'X' would be forced to equal -15. But note that 'X' minus 15, the number above it, equals -30, while '*' minus the number next to it is -10 - 20 = -30. But when now calculating the number 'A' we have A = -15 - 15 - (-20) - B, while when calculating 'C' we have C = -10 - 20 - (-20) - B. Note the last two terms are shared, and as -15 - 15 = -10 - 20 that would imply A = C. This is not allowed, so a(21) cannot be -10. The general rule is if the difference between the number being chosen and its orthogonal neighbor is the same as the difference between the number diagonally adjacent to it with that number's orthogonal neighbor then the chosen number must be rejected. As -10 is not possible and 11 has already appeared a(21) = -11.
Comments