Which Way Do They Move Together?
A monitoring dashboard at Halcyon Freight puts a one-word label beside every pair of tracked metrics, so an operator can see at a glance which way they move together. Each pair is a metric sampled once a week for several weeks, against the week number.
Eyeballing them is not safe: a series can drop, tick back up mid-run, then drop again, and two operators looking at the same handful of points have already disagreed about which label one of them deserves. The label has to fall out of the whole run, not out of where it started and where it ended.
Task: Print exactly one word — positive, negative or zero — according to the sign of the sample covariance between the two columns, with zero reserved for a covariance of exactly zero.
Input
Three lines. The first holds one integer n, the number of weeks (at least 2). The second holds the n week numbers, separated by spaces. The third holds the n sampled values, in the same week order. Values are decimal numbers.
Output
One line holding one of the three words above, in lower case, with no quotation marks.
Example:
Input:
5
1 2 3 4 5
9 2 3 4 5
Output:
negative
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