A163332 Self-inverse permutation of the integers for constructing the Peano curve in an N X N grid.
0, 1, 2, 5, 4, 3, 6, 7, 8, 15, 16, 17, 14, 13, 12, 9, 10, 11, 18, 19, 20, 23, 22, 21, 24, 25, 26, 47, 46, 45, 48, 49, 50, 53, 52, 51, 44, 43, 42, 39, 40, 41, 38, 37, 36, 29, 28, 27, 30, 31, 32, 35, 34, 33, 54, 55, 56, 59, 58, 57, 60, 61, 62, 69, 70, 71, 68, 67, 66, 63, 64, 65
Offset: 0
Keywords
Links
- Antti Karttunen, Table of n, a(n) for n = 0..59048
- Giuseppe Peano, Sur une courbe, qui remplit toute une aire plane, Mathematische Annalen, volume 36, number 1, 1890, pages 157-160. Also EUDML (link to GDZ).
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
Mathematica
a[n_] := FromDigits[With[{d = Reverse@IntegerDigits[n, 3]}, Reverse@Table[ If[EvenQ@Total@d[[j+1 ;; ;; 2]], d[[j]], 2-d[[j]]], {j, Length@d}]], 3]; Array[a, 100] (* Andrey Zabolotskiy, Apr 08 2021, after Kevin Ryde *)
-
PARI
a(n) = my(v=digits(n,3)); for(start=2,3, my(s=0); forstep(i=start,#v,2, s+=v[i-1]; if(s%2,v[i]=2-v[i]))); fromdigits(v,3); \\ Kevin Ryde, Sep 04 2020
Extensions
Name corrected by Kevin Ryde, Aug 27 2020
Comments