Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Corners solution in Uncategorized category for Counting Tiles by bryukh
from math import ceil, sqrt, pow
def checkio(radius):
"""count tiles"""
full, partial = 0, 0
for i in range(1, int(ceil(radius)) + 1):
for j in range(1, int(ceil(radius)) + 1):
far_distance = sqrt(pow(i, 2) + pow(j, 2))
near_distance = sqrt(pow(i - 1, 2) + pow(j - 1, 2))
if far_distance > radius and near_distance < radius:
partial += 1
elif far_distance <= radius:
full += 1
return [full * 4, partial * 4]
Dec. 22, 2012