You will write three functions: the distance between two points, the point that divides a segment in a ratio, and the ratio from a point on the segment. The checker uses both internal and external division.
The idea. The point that divides in the ratio is in each coordinate. For an external division give a negative , so that becomes .
Your tasks.
distance(p, q). Return the distance between two points of space.divide(p, q, m, n). Return the point as a tuple of three numbers.ratio_of(a, b, p). The point p lies on the line a to b. Return using the first coordinate in which b and p differ.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…