Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
7-liner: Points in a Quarter Circle Can Be Useful solution in Clear category for Counting Tiles by Stensen
from itertools import product
from math import ceil, sqrt
def checkio(r):
pts = list(product(range(ceil(r)), repeat=2))
return [
4 * sum([1 for i in pts if 0 not in i and sum(j ** 2 for j in i) < r ** 2]),
4 * sum([1 for i in pts if 0 < r - sqrt(sum(j ** 2 for j in i)) < 1.29])]
Nov. 18, 2020