Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Tiles in a quater times 4 solution in Clear category for Counting Tiles by Vulwsztyn
import math
def checkio(r):
"""count tiles"""
n=math.ceil(r)
g=[]
for i in range(n+1):
g.append([])
for i in range(n+1):
for j in range(n+1):
if i**2+j**2<=r**2:
g[i].append(1)
else:
g[i].append(0)
for i in range(n+1):
print(g[i])
c=[]
for i in range(n):
c.append([])
for i in range(n):
for j in range(n):
if g[i][j]==1 and g[i+1][j]==1 and g[i][j+1]==1 and g[i+1][j+1]==1:
c[i].append(1)
elif g[i][j]==1 or g[i+1][j]==1 or g[i][j+1]==1 or g[i+1][j+1]==1:
c[i].append(2)
else:
c[i].append(0)
for i in range(n):
print(c[i])
s=0
p=0
for i in range(n):
for j in range(n):
if c[i][j]==2:
p+=1
elif c[i][j]==1:
s+=1
return [s*4, p*4]
Nov. 1, 2016