Skip to content

Instantly share code, notes, and snippets.

@kanghyojun
Created May 4, 2013 10:20
Show Gist options
  • Save kanghyojun/5517066 to your computer and use it in GitHub Desktop.
Save kanghyojun/5517066 to your computer and use it in GitHub Desktop.
def draw_circle(r):
space_num = r * 2 + 1
def circle(x, y, radius):
radius_point = (x - radius)**2 + (y - radius) **2
radius_square = radius**2
correct_value = 1
if radius <= 3:
correct_value = 0.7
return radius_square * correct_value <= radius_point <= radius_square * 1.3
for h in range(0, space_num):
for w in range(0, space_num):
if circle(w, h, r):
print("@", end="")
else:
print(" ", end="")
print("")
if __name__ == "__main__":
for x in range(1, 14):
print("Drawing {0} radius circle".format(x))
draw_circle(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment