A Perfectly Inverse Relationship
Still cleaning the Halcyon Freight feed. The pairs of columns still to screen move the other way: as one climbs, the other falls. The first of them is two views of the same fixed load — pallets dispatched and pallets still on the dock.
A junior on the team has proposed keeping both columns on the grounds that "a negative relationship is a weak one, so there's no duplication to worry about". You need the number on the record before that reasoning goes any further, for this pair and for the downhill pairs behind it.
Task: Print the Pearson correlation coefficient between the two columns, rounded to 2 decimals.
Input
Three lines. The first holds one integer n, the number of sampled rows (at least 2). The second holds the n values of the first column, separated by spaces. The third holds the n values of the second column, in the same row order. Values are decimal numbers, and neither column is constant.
Output
One line holding the coefficient, rounded to 2 decimals and printed the way Python prints a float — -1.0, never -1.00.
Example:
Input:
5
1 2 3 4 5
10 8 6 4 2
Output:
-1.0
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