We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Test case: 4 2 WWBW has expected answer of 1.8333333333. The only way to get that answer based on the very limited instruction case logic is as follows:
Level 1: WWBW = 1 - you can get a white ball every time.
Level 2: WBW and WWB.
WBW = 2/3
WWB = 1
Final answer: (2/3 + 1) / 2 (for the two row possibilities in level 2) + 1 for the original = 1.833333 Ok, cool, so far so good.
Following that logic,
Test case: 5 3 WWWBW
Level 1: WWWBW = 1, you can get a white ball every time.
Level 2 has two unique row possibilities: WWBW and WWWB.
WWBW = 1
Level 3 for WWBW has two unique rows: WBW and WWB:
WBW = 2/3 and WWB = 1 and add (2/3 + 1) / 2 to WWBW's 1 for a total of 1.91666666 for the WWBW possibility.
WWWB = 1
Level 3 for WWWB has only one unique row possibility, WWB, which is also 1.
so, WWWB has a total white ball probability of 1 + (1/1) = 2.
Then, going back up to level 1, divide both the WWBW and WWWB row totals by 2 and add to the original 1 for WWWBW for a total of 2.9166666.
But, the expected test case answer is 2.9000000000. Can anyone explain please?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Choosing White Balls
You are viewing a single comment's thread. Return to all comments →
What am I missing here?
Test case: 4 2 WWBW has expected answer of 1.8333333333. The only way to get that answer based on the very limited instruction case logic is as follows: Level 1: WWBW = 1 - you can get a white ball every time. Level 2: WBW and WWB. WBW = 2/3 WWB = 1
Final answer: (2/3 + 1) / 2 (for the two row possibilities in level 2) + 1 for the original = 1.833333 Ok, cool, so far so good.
Following that logic, Test case: 5 3 WWWBW Level 1: WWWBW = 1, you can get a white ball every time.
Level 2 has two unique row possibilities: WWBW and WWWB. WWBW = 1
Level 3 for WWBW has two unique rows: WBW and WWB: WBW = 2/3 and WWB = 1 and add (2/3 + 1) / 2 to WWBW's 1 for a total of 1.91666666 for the WWBW possibility.
WWWB = 1
Level 3 for WWWB has only one unique row possibility, WWB, which is also 1.
so, WWWB has a total white ball probability of 1 + (1/1) = 2.
Then, going back up to level 1, divide both the WWBW and WWWB row totals by 2 and add to the original 1 for WWWBW for a total of 2.9166666.
But, the expected test case answer is 2.9000000000. Can anyone explain please?