Birthday odddays

Here is an interesting factoid: “On the planet Earth, if there are at least 23 people in a room,
the chance that two of them have the same birthday is greater than 50%.”
You would like to come up with more factoids of this form.

Given two integers (minOdds and daysInYear), your method should return the fewest number of people (from a planet where there are daysInYear days in each year) needed such that you can be at least minOdds% sure that two of the people have the same birthday. See example 0 for further information
Given 2 integers A and B.

Return the fewest number of people (from a planet where there are B days in each year) needed such that you can be at least A percent sure that two of the people have the same birthday.

See example 1 for further information



Input Format

The first argument given is the integer A.
The second argument given is the integer B.

Output Format

Return the fewest number of people (from a planet where there are B days in each year) needed such that you can be at least A percent sure that two of the people have the same birthday. 

Constraints

1 <= A <= 99
1 <= B <= 10000

For Example

Example Input 1:
    A = 75
    B = 5
Example Output 1:
    4
Example Explanation 1:
    We must be 75% sure that at least two of the people in the room have the same birthday. This is equivalent to saying that the odds of everyone having different birthdays is 25% or less.
    
    1.If there is only one person in the room, the odds are 5/5 or 100% that nobody shares a birthday.
    
    2.If there are two people in the room, the odds are 5/5 * 4/5 = 80% that nobody shares a birthday. This is because the second person has 4 "safe" days on which his birthday could fall, out of 5 possible days in the year.
    
    3.If there are three people in the room, the odds of no overlap are 5/5 * 4/5 * 3/5 = 48%.
    
    4.If there are four people in the room, the odds are 5/5 * 4/5 * 3/5 * 2/5 = 19.2%. This means that you can be (100% - 19.2%) = 80.8% sure that two or more of them do, in fact, have the same birthday.
    
    We only need to be 75% sure of this, which was untrue for three people but true for four. Therefore, your method should return 4.
    
Input 2:
    A = 50
    B = 365
Output 2:
    23
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Birthday odddays on Interview Code Editor
Sign Up
to access hints and editorial solutions for Birthday odddays

Discussion


Loading...
Click here to start solving coding interview questions