Programs often list outcome statistics, such as this:
- 54% of participants received an award
- 69% of participants got a promotion
- 85% of participants increased their salary
These percentages are the result of dividing a/x, where both a and x are whole numbers, and the result is rounded to the nearest hundredth.
Your task is to, given a set of percentages of arbitrary length and an arbitrary precision to which these percentages are rounded, find the three smallest whole numbers x of participants which could result in the given statistics.
To standardize answers, let's presume your input percentages are given as floating or fixed point decimals (your choice) like 0.54 and 0.69, and a precision given as an integer such as 2 meaning two digits past the decimal point.
For the above statistics, the first smallest number of participants is 13, and the 7, 9, and 11 participants had each of the given outcomes. Thus, 13 would be the first number in a set of three output numbers.
The winner will be the shortest piece of code counted in bytes. Any rounding method is acceptable in solutions, but solutions that offer solutions for multiple rounding schemes (floor, ceiling, or nearest) are encouraged.
Another example in Ruby
percentages = [ 0.5, 0.67, 0.83, 1.0 ]
precision = 2
smallest_group_size(percentages, precision) # Should produce [6, 12, 18]
(1.35).toFixed(1)
is 1.4 but(0.35).toFixed(1)
is 0.3. \$\endgroup\$