login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A220102 Permutation of natural numbers arising from applying the walk of square spiral (e.g. A214526) to the data of double square spiral (defined in A220098). 0
1, 2, 4, 6, 8, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 50, 52, 54, 56 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
PROG
(C)
#include <stdio.h>
#define SIZE 20
int grid[SIZE][SIZE];
int direction[] = {0, -1, 1, 0, 0, 1, -1, 0};
main() {
int i, j, x1, y1, x2, y2, stepSize;
int direction1pos=0, direction2pos=4, val;
x1 = y1 = x2 = y2 = SIZE/2;
for (val=grid[y1][x1]=1, stepSize=0; ; ++stepSize) {
if (x1<1 || x1>=SIZE-1 || x2<1 || x2>=SIZE-1) break;
if (y1<1 || y1>=SIZE-1 || y2<1 || y2>=SIZE-1) break;
for (i=stepSize|1; i; ++val, --i) {
x1 += direction[direction1pos ];
y1 += direction[direction1pos+1];
x2 += direction[direction2pos ];
y2 += direction[direction2pos+1];
grid[y1][x1] = val*2;
grid[y2][x2] = val*2+1;
}
direction1pos = (direction1pos+2) & 7;
direction2pos = (direction2pos+2) & 7;
}
direction1pos=0;
x1 = y1 = SIZE/2;
for (stepSize=2; ; ++stepSize) {
for (i=stepSize/2; i; --i) {
if (grid[y1][x1]==0) return;
printf("%d, ", grid[y1][x1]);
x1 += direction[direction1pos ];
y1 += direction[direction1pos+1];
}
direction1pos = (direction1pos+2) & 7;
}
}
CROSSREFS
Sequence in context: A004093 A106202 A351330 * A308080 A179657 A239887
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Dec 04 2012
STATUS
approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 28 09:38 EDT 2024. Contains 375481 sequences. (Running on oeis4.)