Skip to content

Instantly share code, notes, and snippets.

@Armen138
Created August 17, 2012 20:36
Show Gist options
  • Save Armen138/3382383 to your computer and use it in GitHub Desktop.
Save Armen138/3382383 to your computer and use it in GitHub Desktop.
Spiral
var x = 0,
y = 0,
dx = 0,
dy = -1;
for(var i = 0; i < 10; i++) {
if( (x == y) || ((x < 0) && (x == -y)) || ((x > 0) && (x == 1-y))){
t = dx;
dx = -dy;
dy = t;
}
x += dx;
y += dy;
console.log({X: x, Y: y});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment