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
-
25347 Solvers
-
1649 Solvers
-
233 Solvers
-
Replace multiples of 5 with NaN
440 Solvers
-
Generate a random matrix A of (1,-1)
313 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!