Note: as this question has been marked as a duplicate, I have accepted an answer. However, I will still check this question if users can find a shorter way of doing it, and accept that answer.
Given two numbers (which are multiples of 0.5
) representing heads-percentage
and tails-percentage
from a series of coin-flipping, output the minimum amounts of heads and tails to produce percentages such as those. Input and output can be in any form. However, output must be in a readable format (Good examples are x y
, [x y]
, etc).
Examples:
- Input:
25 75
(25% heads, 75% tails) Output:1 3
(an output of25 75
is invalid since that is not the minimum amounts of heads and tails to produce those percentages) - Input:
30 70
(30% heads, 70% tails) Output:3 7
- Input:
99.5 0.5
(99.5% heads, 0.5% tails) Output:199 1
You may assume that there will always be a digit before and after a decimal point in an input (no .5
s or 15.
s). You may also assume the input adds up to 100%. This is code-golf, shortest code in bytes wins!
[199.0, 1.0]
a valid output for the last example? \$\endgroup\$