Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Counting Tiles by MichalMarsalek
import math
def checkio(radius):
solid = 0
partial = 0
n = math.floor(radius) + 1 #Max square coordinates evaulated
for y in range(n):
for x in range(n): #Iterates throught first quandrant
if math.hypot(x+1, y+1) <= radius: #If top right corner is inside a circle
solid += 1 #then whole square is inside a circle
elif math.hypot(x, y) < radius: #If bottom left corner is inside a circle
partial += 1 #then part of a square is inside a circle
return [solid*4, partial*4] #Multiplies values by 4 to register all quadrants
April 6, 2014
Comments: