Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created July 11, 2020 09:12
Show Gist options
  • Select an option

  • Save gr33n7007h/d044e800c9f60eaa25a5b7b2fa89e1b3 to your computer and use it in GitHub Desktop.

Select an option

Save gr33n7007h/d044e800c9f60eaa25a5b7b2fa89e1b3 to your computer and use it in GitHub Desktop.
ascii circles.
def circle(radius: 10)
0.step(to: radius << 1, by: 1) do |x|
0.step(to: radius << 1, by: 1) do |y|
dist = ((x - radius).abs2 + (y - radius).abs2) ** 0.5
dist.between?(radius - 0.5, radius + 0.5) ? $> << ?. : $> << ' '
end
$> << $/
end
end
5.step to: 20, by: 4 do |radius|
circle radius: radius
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment