The Other Urn
The same Harlow & Co. prize stall, the same closing-time puzzle. Two urns, each with its own mix of red and blue tokens, a wheel that sends each visitor to one urn or the other, and a single red token on the counter with no record of where it came from.
The stock sheet has a line for each urn, and the manager wants both lines filled in with real numbers rather than one number and a subtraction. So this time: how likely is it that the red token came out of Urn B?
The stall is re-set for each convention with different token mixes and a differently weighted wheel. Assume the urn was full and exactly one token was drawn.
Task: Print the probability that the red token came from Urn B, as a single number rounded to 4 decimals. Round once, at the end.
Input
Four lines, each a decimal between 0 and 1: the chance the wheel sends a visitor to Urn A, the chance it sends them to Urn B, the share of Urn A's tokens that are red, and the share of Urn B's tokens that are red. The two wheel chances add to 1.
Output
One line holding the probability, rounded to 4 decimals and printed the way Python prints a float - 0.6667.
Example:
Input:
0.5
0.5
0.3
0.6
Output:
0.6667
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in