The Hope Function
Description:
Suppose you believe that a piece of treasure is hidden in one of n boxes. Before you start looking, you estimate there is probability p that the treasure is in any of the boxes at all. As you open more and more of the boxes, what happens to the probability that the treasure is in the next box you'll open? And what is the probability that the treasure will be in any of the remaining boxes at all?
Please note: the harder part of this problem is the maths/probability side, rather than the coding/implementation side. If you'd like to skip ahead to implmementation, you can implement the formulas given here.
Given p (the prior probability that the treasure is in any of the boxes, n (the total number of boxes) and i (the number of boxes you have already searched without finding the treasure), return a list with two elements: the probability that the treasure will be in the next (i+1th) box, and the probability that the treasure will be in any of the remaining boxes at all.
Assume at all times that, if the treasure is there at all, it's equally likely to be in any of the remaining boxes.
Note: to tolerate floating point error, the tests use approx_equals with margin 1e-02
Similar Kata:
Stats:
Created | Apr 6, 2019 |
Warriors Trained | 11 |
Total Skips | 0 |
Total Code Submissions | 22 |
Total Times Completed | 3 |
Python Completions | 3 |
Total Stars | 0 |
% of votes with a positive feedback rating | 0% of 1 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 2 |
Average Assessed Rank | 8 kyu |
Highest Assessed Rank | 8 kyu |
Lowest Assessed Rank | 8 kyu |