diff --git a/README.rst b/README.rst index 2c05b56..7b9a0a3 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -=================== +=================== 100 numpy exercises =================== @@ -597,9 +597,12 @@ Thanks to Michiaki Ariga, there is now a how to compute distance from each point j (P[j]) to each line i (P0[i],P1[i]) ? .. code-block:: python - - Answer needed actually - + # Author: Italmassov Kuanysh + # based on distance function from previous question + P0 = np.random.uniform(-10, 10, (10,2)) + P1 = np.random.uniform(-10,10,(10,2)) + p = np.random.uniform(-10, 10, (10,2)) + print np.array([distance(P0,P1,p_i) for p_i in p]) #. Consider an arbitrary array, write a function that extract a subpart with a fixed shape and centered on a given element (pad with a ``fill`` value when