Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short solution in Speedy category for Counting Tiles by Sim0000
from math import sqrt, ceil
def checkio(r):
return [4*sum(int(sqrt(r*r-x*x)) for x in range(1,int(r)+1)), 8*ceil(r)-4]
# The solid can be calculated as sum of height.
# The partial can be calculated deterministically by O(1).
#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"
April 5, 2014
Comments: