Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Counting Tiles by erewhon
import math
def checkio(radius):
perfect_tiles = 0
partial_tiles = 0
for x in range(math.ceil(radius)):
for y in range(math.ceil(radius)):
lower_left_length = math.sqrt(x ** 2 + y ** 2)
upper_right_length = math.sqrt((x + 1) ** 2 + (y + 1) ** 2)
if lower_left_length < radius:
if upper_right_length < radius:
perfect_tiles += 1
else:
partial_tiles += 1
result = [perfect_tiles * 4, partial_tiles * 4]
return result
June 29, 2020