Problem 44695. What score did they give?
Your task in this problem is to figure out the most recent score, S, submitted.
Many websites allow users to rate things like restaurants, books, films, and even computer programs. Often these are rated from one to five stars, and the display shows the average rating after rounding to one decimal place, R, and the number of users who have rated the item/place/thing, N.
This morning you checked the website and noted R and N. This evening you check again: N has increased by one, and the rounded version of the updated overall rating is now displayed, R_new. You then deduce what possible scores, S, were submitted by the additional person during the day.
EXAMPLE
% Inputs N = 11 R = 2.5 R_new = 2.6 % Output S = [3 4]
Explanation: Given N=11, the unrounded version of R must have been either 2 ⁵/₁₁ or 2 ⁶/₁₁. Increasing N by 1 with an additional score of either 4 stars or 3 stars (respectively) would mean that the unrounded version of R_new would become 2 ⁷/₁₂, consistent with the displayed value.
S shall be a row vector, or scalar, or empty. If S is a row vector, scores shall be listed in ascending order, without repetition.
Solution Stats
Problem Comments
-
1 Comment
I can see banning regexp etc., but banning ans?
Solution Comments
Show commentsProblem Recent Solvers9
Suggested Problems
-
7280 Solvers
-
4232 Solvers
-
1265 Solvers
-
Back to basics 13 - Input variables
266 Solvers
-
Back to basics 23 - Triangular matrix
984 Solvers
More from this Author32
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!