First off, leap years are not being considered for this. In fact the year that people are born shouldn't be taken into consideration, for simplicity.

The basic question is given an input, a single integer representing the number of people in the room (X >= 1). Return the probability that 2 or more people share the same birthday.

The return from the function should be a value between 0 and 1, inclusive. It should also be rounded out to the 10 thousandth decimal point (4 after the decimal point). There should be no trailing zeros included.

Show
1 older comment

Gary
on 19 Apr 2012

I think there might be something wrong with the test suite. When I run in Matlab, my answers match what the test suite is looking for, yet it still shows a failure.

Venu Lolla
on 19 Apr 2012

Ben, your description suggests that rounding to 4 decimal places is optional. Perhaps you can clarify that. Test case with x = 365 is weird. The probability that no one shares a birthday for that x is close to 1.4550e-157 which is neglected during the rounding and hence highly probable event becomes a certainty !!

Ben Ausdenmoore
on 20 Apr 2012

@Gary What you might be seeing is that the default output from Matlab is only 5 digits (generally). So you're probably seeing something like 0.0027 for X = 2 but if you multiply that answer by 1000 you will see there are still some digits trailing after the 7.
@Venu I think that's just an issue with how I did the calculation on my end. You're right that I should have it as 0.9999 in the test suite even though that is super close to 1 (the actual probability). I'll also make it clear in the brief that the answer should be out to 4 decimal points.

Richard Zapor
on 28 May 2012

The problem should state truncate at the 10 thousandth point. n=50 is .97037 so the correct rounded answer is .9704 not .9703.

1 Comment

yurenchu
on 6 Mar 2017

Cheating solution.

**Tags**

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
3 players like this problem

3 players like this problem