Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Counting Tiles by MichalMarsalek
import math
def checkio(radius):
dist = lambda x,y: math.sqrt(x*x + y*y) #Calculates distance to [0,0]
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 dist(x+1, y+1) <= radius: #If top right corner is inside a circle
solid += 1 #then whole square is inside a circle
elif dist(x+1, y) <= radius or dist(x, y+1) <= radius or dist(x, y) < radius: #If one of the other corners 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