Reading the Direction of a Relationship
Kestrel Freight's depot dashboard has a row of tiny arrows, one per pair of columns it tracks — an arrow up if the second column tends to rise as the first one does, an arrow down if it tends to fall, and a dash if there is no tilt at all. Nobody reads a number off that row, so the size of the relationship is not wanted; only its direction is. The dashboard refreshes constantly, which is why it asks for the direction alone rather than a full fit.
Task: Print which way the least-squares line through these points would tilt.
Input
The first line holds one integer n, the number of points, where 2 <= n <= 1000. Then come n lines, each holding two numbers separated by a single space: the first column's value and the second column's value for one point.
Output
One line, exactly one of positive if that line would tilt upward, negative if it would tilt downward, or zero if it would be exactly flat. zero means exactly zero tilt, with no tolerance and no rounding applied first.
Example:
Input:
3
1 2
2 4
3 6
Output:
positive
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in