Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Counting Tiles solution in Clear category for Counting Tiles by JimmyCarlos
def checkio(radius):
from math import ceil
point_is_in=lambda x,y,r: x**2 + y**2 <= r**2
full_tiles,part_tiles = 0,0
for x in range(ceil(radius)):
for y in range(ceil(radius)):
corners_in = len([(X,Y) for X,Y in [(x,y),(x+1,y),(x,y+1),(x+1,y+1)] if point_is_in(X,Y,radius)])
if corners_in == 4: full_tiles += 1
elif corners_in > 0: part_tiles += 1
return [4*full_tiles,4*part_tiles]
Sept. 27, 2019