Skip to content

Instantly share code, notes, and snippets.

@thinkerbot
Last active August 29, 2015 14:16
Show Gist options
  • Save thinkerbot/418d5f464cf1addccbd2 to your computer and use it in GitHub Desktop.
Save thinkerbot/418d5f464cf1addccbd2 to your computer and use it in GitHub Desktop.
x, y = 0, 0
xmin, xmax, ymin, ymax = 0, 0, 0, 0
e = Enumerator.new do |yy|
loop do
while x > xmin
yy << [x, y]
x -= 1
end
xmin -= 1
while y < ymax
yy << [x, y]
y += 1
end
ymax += 1
while x < xmax
yy << [x, y]
x += 1
end
xmax += 1
while y > ymin
yy << [x, y]
y -= 1
end
ymin -= 1
end
end
xmin, xmax, ymin, ymax = 1, 5, 1, 5
dx = 1
dy = 1
e = Enumerator.new do |yy|
x = xmin
y = ymin
while y <= ymax
while x <= xmax
yy << [x, y]
x += dx
end
x = xmin
y += dy
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment