|
1
|
|
|
from math import ceil, hypot |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
def getMaxAndMinDistances(radius): |
|
5
|
|
|
radius = int(ceil(radius)) |
|
6
|
|
|
distances = [] |
|
7
|
|
|
for row in range(radius): |
|
8
|
|
|
for col in range(radius): |
|
9
|
|
|
temp = [ |
|
10
|
|
|
hypot(row - radius, col - radius), |
|
11
|
|
|
hypot(row - radius, radius - col - 1), |
|
12
|
|
|
hypot(radius - row - 1, radius - col), |
|
13
|
|
|
hypot(radius - row - 1, radius - col - 1), |
|
14
|
|
|
] |
|
15
|
|
|
distances.append((min(temp), max(temp))) |
|
16
|
|
|
return distances |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
def checkio(radius): |
|
20
|
|
|
distances = getMaxAndMinDistances(radius) |
|
21
|
|
|
solid = len(list(filter(lambda x: x[1] < radius, distances))) |
|
22
|
|
|
partial = len(list(filter(lambda x: x[1] > radius > x[0], distances))) |
|
23
|
|
|
"""count tiles""" |
|
24
|
|
|
return [solid * 4, partial * 4] |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
# These "asserts" using only for self-checking and not necessary for |
|
28
|
|
|
# auto-testing |
|
29
|
|
|
if __name__ == '__main__': |
|
30
|
|
|
assert checkio(2) == [4, 12], "N=2" |
|
31
|
|
|
assert checkio(3) == [16, 20], "N=3" |
|
32
|
|
|
assert checkio(2.1) == [4, 20], "N=2.1" |
|
33
|
|
|
assert checkio(2.5) == [12, 20], "N=2.5" |
|
34
|
|
|
|