53. Average rating of movies

The problem requires the computing of a movie rating using a truncated mean. This is a statistical measure of a central tendency where the mean is calculated after discarding parts of a probability distribution or sample at the high and low ends. Typically, this is done by removing an equal amount of points at the two ends. For this problem, you are required to remove 5% of both the highest and lowest user ratings.

A function that calculates a truncated mean for a given range should do the following:

  • Sort the range so that elements are ordered (either ascending or descending)
  • Remove the required percentage of elements at both ends
  • Count the sum of all remaining elements
  • Compute the average by dividing the sum ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.