Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Counting Tiles by Andreas_Strus
def checkio(radius):
"""count tiles"""
x = 0 #NUmber of full tiles
r = radius
y =0
a = [0, 1, 2, 3, 4]
b = [0, 1, 2, 3, 4]
for m in a:
for n in b:
print (m, n)
print(x , " ", y)
if ((m**2 + n**2)**0.5) < radius:
print("1. ====", ((m**2 + n**2)**0.5))
y = y + 1
if (((m + 1)**2 + (n + 1)**2)**0.5) < radius:
print("2. ====", (((m + 1)**2 + (n + 1)**2)**0.5))
y = y - 1
x = x + 1
return [4 * x, 4 * y]
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(2) == [4, 12], "N=2"
assert checkio(3) == [16, 20], "N=3"
assert checkio(2.1) == [4, 20], "N=2.1"
assert checkio(2.5) == [12, 20], "N=2.5"
Oct. 27, 2016