login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A163332 Self-inverse permutation of integers for constructing Hilbert II curve in N x N grid. 11
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

The integers [0,(3^k)-1] are confined to range [0,(3^k)-1].

LINKS

A. Karttunen, Table of n, a(n) for n = 0..59048

Index entries for sequences that are permutations of the natural numbers

PROG

(MIT Scheme:)

(define (A163332 n) (let loop ((z 0) (n n) (i 0)) (let ((x (modulo n 3)) (y (modulo (floor->exact (/ n 3)) 3))) (cond ((zero? n) z) ((and (= 1 x) (= 1 y)) (loop (+ (* 4 (expt 3 i)) (complement-i-lsts z i)) (floor->exact (/ n 9)) (+ i 2))) ((= 1 x) (loop (+ (* (+ (* y 3) 1) (expt 3 i)) (complement-i-oddpos-lsts z (/ i 2))) (floor->exact (/ n 9)) (+ i 2))) ((= 1 y) (loop (+ (* (+ 3 (- 2 x)) (expt 3 i)) (complement-i-evenpos-lsts z (/ i 2))) (floor->exact (/ n 9)) (+ i 2))) (else (loop (+ (* (+ (* y 3) x) (expt 3 i)) z) (floor->exact (/ n 9)) (+ i 2)))))))

(define (complement-i-lsts n i) (if (zero? i) n (+ (- 2 (modulo n 3)) (* 3 (complement-i-lsts (floor->exact (/ n 3)) (-1+ i))))))

(define (complement-i-evenpos-lsts n i) (if (zero? i) n (+ (- 2 (modulo n 3)) (* 3 (complement-i-oddpos-lsts (floor->exact (/ n 3)) (-1+ i))))))

(define (complement-i-oddpos-lsts n i) (+ (* 3 (complement-i-evenpos-lsts (floor->exact (/ n 3)) i)) (modulo n 3)))

CROSSREFS

a(n) = A163327(A163333(A163327(n))). A163334 & A163336 give two variants of Hilbert II curve in N x N grid. Cf. also A163355.

Sequence in context: A111449 A210800 A222235 * A275105 A128173 A265362

Adjacent sequences:  A163329 A163330 A163331 * A163333 A163334 A163335

KEYWORD

nonn

AUTHOR

Antti Karttunen, Jul 29 2009

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 22 09:52 EST 2019. Contains 319363 sequences. (Running on oeis4.)