All problems

A Simplified Silhouette Score

mediumPythonK-Means Clustering

Wexford Couriers wants to know whether one particular address is sitting in the right cluster. Two averages have already been worked out for it. The first, a, is its average travel to the other addresses in its own cluster. The second, b, is its average travel to the addresses of the nearest other cluster. The planners want those two turned into one score on a fixed scale, so that addresses from opposite ends of the city can be compared: the gap between the two averages, scaled against the larger of them. Negative scores are allowed, and are the interesting ones.

Task: Print this address's score.

Input

One line holding two numbers separated by a single space: a, then b. Neither is negative and they are never both zero.

Output

One line holding the score rounded to 4 decimal places. It comes out positive when the address is better off where it is, negative when it would be better off in the neighbouring cluster, and exactly zero when the two averages match, whatever size they are. A negative score is printed as it stands, never flattened to zero.

Example:

Input:
1 3

Output:
0.6667

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…