Python,
pasted
on Nov 4:
|
import math
from itertools import chain
def get_list(n, r):
def process_coord(x, y):
base_angle = math.atan2(y, x)
delta_angle = math.asin(r / (math.sqrt(x * x + y * y)))
yield (base_angle - delta_angle, 1)
yield (base_angle + delta_angle, -1)
return chain.from_iterable(process_coord(x, y) for x in xrange(0, n)
for y in xrange(0, x)
if (x * x + y * y < n * n) and (x * x + y * y > 0))
def main():
l = get_list(100, 0.02)
print len(list(l))
if __name__ == '__main__':
main()
|
Output:
|
Traceback (most recent call last):
Line 22, in <module>
main()
Line 18, in main
l = get_list(100, 0.02)
Line 12, in get_list
return chain.from_iterable(process_coord(x, y) for x in xrange(0, n)
AttributeError: type object 'itertools.chain' has no attribute 'from_iterable'
|
|