Thinkful - Logic Drills: Red and bumpy
Description:
You're playing a game with a friend involving a bag of marbles. In the bag are ten marbles:
- 1 smooth red marble
- 4 bumpy red marbles
- 2 bumpy yellow marbles
- 1 smooth yellow marble
- 1 bumpy green marble
- 1 smooth green marble
You can see that the probability of picking a smooth red marble from the bag is 1 / 10
or 0.10
and the probability of picking a bumpy yellow marble is 2 / 10
or 0.20
.
The game works like this: your friend puts her hand in the bag, chooses a marble (without looking at it) and tells you whether it's bumpy or smooth. Then you have to guess which color it is before she pulls it out and reveals whether you're correct or not.
You know that the information about whether the marble is bumpy or smooth changes the probability of what color it is, and you want some help with your guesses.
Write a function that takes two arguments: a color ('red'
, 'yellow'
, or 'green'
) and a texture ('bumpy'
or 'smooth'
) and returns the probability as a decimal fraction accurate to two places.
The probability should be a string and should discard any digits after the 100ths place. For example, 2 / 3
or 0.6666666666666666
would become the string '0.66'
. Note this is different from rounding.
As a complete example, 'red', 'bumpy'
should return the string '0.57'
.
Similar Kata:
Stats:
Created | Dec 29, 2016 |
Published | Dec 29, 2016 |
Warriors Trained | 2188 |
Total Skips | 64 |
Total Code Submissions | 6593 |
Total Times Completed | 1480 |
Python Completions | 1294 |
Crystal Completions | 10 |
JavaScript Completions | 183 |
Ruby Completions | 36 |
Total Stars | 31 |
% of votes with a positive feedback rating | 78% of 202 |
Total "Very Satisfied" Votes | 131 |
Total "Somewhat Satisfied" Votes | 52 |
Total "Not Satisfied" Votes | 19 |
Total Rank Assessments | 13 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |