Premium problem79. Distance Points to Lines

Hard Locked

Given sets of points P0, P1 (shape (n, 2)) describing lines and a set of points P (shape (m, 2)), return the (m, n) distances from each point to each line.

Input

P0 =
[[0. 0.]
 [0. 0.]]
P1 =
[[1. 0.]
 [0. 1.]]
P =
[[1. 1.]
 [2. 0.]]

Output

[[1. 1.]
 [0. 2.]]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)