A283618 A 2D -> 1D binary encoding of points (x,y) of the square lattice such that x >= 0 and 0 <= y <= x, and ranked in order of increasing distance from the origin. Equidistant points are ranked in order of increasing ordinate.
0, 2, 3, 8, 9, 12, 10, 11, 14, 32, 33, 15, 36, 34, 37, 35, 38, 48, 39, 40, 41, 44, 50, 45, 42, 43, 51, 56, 46, 47, 57, 128, 129, 58, 132, 60, 133, 59, 144, 130, 131, 134, 62, 145, 135, 146, 63, 136, 148, 137, 140, 147, 141, 149, 152, 150, 138, 139, 142, 153, 192, 143, 151, 156, 154, 160, 161, 194, 155, 164, 157, 165
Offset: 1
Links
- Andres Cicuttin, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
(* Maximum explorative abscissa *) xmax=20; (* points in the triangle of vertices (0,0),(0,max) and (xmax,xmax) *) points=Flatten[Table[{x,y},{x,0,xmax},{y,0,x}],1]; (* Sorting points: first by increasing distance from origin, and then by increasing ordinate *) sortedpoints=SortBy[points,{#[[1]]^2+#[[2]]^2&,#[[2]]&}]; (* Safe limit for correctly sorted sequence *) nmax=Floor[xmax^2/4]; (* Separate lists of abscissas and ordinates *) abs=Transpose[sortedpoints][[1]][[1;;nmax]]; ord=Transpose[sortedpoints][[2]][[1;;nmax]]; (* Definition of the 2D -> 1D binary encoding function: *) MergerEncoder[a_,b_]:=Module[{x,maxbits}, maxbits=32; (* for a,b < 2^32-1, increase this value for larger integers *) x={IntegerDigits[a,2,maxbits], IntegerDigits[b,2,maxbits]}//Transpose//Flatten; FromDigits[x,2]//Return]; a= Table[MergerEncoder[abs[[n]],ord[[n]]],{n,1,nmax}]
Comments