diff --git a/week10/calc_pi_np.py b/week10/calc_pi_np.py new file mode 100644 index 0000000..050c37a --- /dev/null +++ b/week10/calc_pi_np.py @@ -0,0 +1,56 @@ +import numpy as np +import argparse +import random +from utils import format_time + +def point_in_circle(coord, radius=1): + """ + Checks whether a point (x, y) is part of a circle with a set radius. + + example + ------- + >>> point_in_circle(0, 0) + True + + """ + r = np.sqrt(np.square(coord).sum(axis=1)) + return r[r