Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Counting Tiles solution in Speedy category for Counting Tiles by Tavisevik
def checkio(radius):
"""count tiles"""
k1 = 0
k2 = 0
i = 0
while i < radius:
j = 0
while j < radius:
if (i+1)**2 + (j+1)**2 <= radius ** 2:
k1 += 1
if i**2 + j**2 <= radius**2 and not((i+1)**2 + (j+1)**2 <= radius ** 2):
k2 += 1
j += 1
i += 1
return [k1*4, k2*4]
#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"
Dec. 15, 2020