Created
July 11, 2020 09:12
-
-
Save gr33n7007h/d044e800c9f60eaa25a5b7b2fa89e1b3 to your computer and use it in GitHub Desktop.
ascii circles.
This file contains hidden or 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
| 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