A383191 a(n) is the number on the n-th position on the square spiral on the plane tiled with dominoes always placed nearest to the origin and so that no two dominos share a long side. Inverse permutation of A383190.
0, 1, 8, 2, 3, 4, 5, 6, 10, 11, 12, 9, 26, 15, 14, 18, 19, 17, 16, 20, 21, 22, 7, 24, 28, 29, 42, 13, 36, 27, 66, 39, 38, 30, 31, 44, 45, 41, 40, 32, 33, 46, 47, 48, 23, 34, 25, 50, 68, 69, 76, 43, 52, 37, 70, 67, 108, 73, 72, 55, 54, 58, 59, 80, 81, 75, 74, 57, 56, 60, 61, 84, 85, 86, 49, 62
Offset: 0
Keywords
Examples
The first domino (0, 1) is placed on the origin and the square to its right. The second domino (2, 3) is placed above the origin (nearest free point coming first counter-clockwise), oriented to the left (since going to the right would place it side-by-side with the first domino, which is forbidden). Then the third domino (4, 5) is placed left to the origin, going downwards (using the free point closest to the origin). The fourth domino (6, 7) is placed below the origin, going downwards (since going to the right would make it parallel to the first domino). Then the free points nearest to the origin are to its lower right and to its upper right. The upper right is preferred since it comes first counter-clockwise (starting to the right). The domino (8, 9) is placed sidewards, again because the other end upwards) would come later in counter-clockwise sense. Then the domino (10, 11) is placed to the lower right, also sideways because vertically it would be side-by-side with (6, 7). The first 16 dominoes are placed as follows, where the numbers (2n-2, 2n-1) represent the two ends of the n-th domino: | | 19==18 14==15 26==27 | | 17 3===2 8===9 | || | 16 4 0===1 12==13 The sequence is obtained by reading the numbers | ‖ along the square spiral: starting at the origin | 20 5 6 10==11 (0), go 1 right (1), 1 up (8), 2 left (2 and 3), | || ‖ 2 down (4 and 5), 3 right (6, 10, 11), 3 up | 21 22 7 24 28==29 (12, 9, 26) 4 left (15, 14, 18, 19), etc. | || || | 23 25 | We see that all dominoes in the upper right half plane are placed horizontally, and in the lower left half they are placed "vertically".
Crossrefs
Programs
-
Python
class A383191(A383190): # use A383191(n) or a=A383191(); a(n); a[m:n]; print(a) def _call_(self, n: int) -> int: "Return A383191(n)." if isinstance(n, int) and n >= 0: while n not in self.terms: self.extend() return self.terms.index(n) # this is the inverse permutation of 'terms' if n is None: return self # because A383191() => A383190(n=None) => a(n) raise ValueError(f"Expected non-negative index n, got {n = !r}.") A383191()[:50] # list [a(0) .. a(49)] print(A383191()) # displays the grid filled so far (same as A383190)
Comments