Last active
August 29, 2015 14:16
-
-
Save thinkerbot/418d5f464cf1addccbd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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