Cody

Problem 1267. Calculate the probability that at least two people in a group share the same birthday.

Solution 2720997

Submitted on 21 Jul 2020 by Ramesh Kumar V
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 1; y_correct = 0.00; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 365 p1 = 365 y = 0

2   Pass
n = 366; y_correct = 1.00; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

y = 1

3   Pass
n = 0; y_correct = 0.00; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p1 = 1 y = 0

4   Pass
n = 23; y_correct = 0.5073; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 365 p = 132860 p = 48228180 p = 1.7459e+10 p = 6.3026e+12 p = 2.2689e+15 p = 8.1454e+17 p = 2.9161e+20 p = 1.0410e+23 p = 3.7061e+25 p = 1.3157e+28 p = 4.6574e+30 p = 1.6441e+33 p = 5.7871e+35 p = 2.0313e+38 p = 7.1095e+40 p = 2.4812e+43 p = 8.6346e+45 p = 2.9962e+48 p = 1.0367e+51 p = 3.5766e+53 p = 1.2303e+56 p = 4.2201e+58 p1 = 8.5652e+58 y = 0.5073

5   Pass
n = 50; y_correct = 0.9704; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 365 p = 132860 p = 48228180 p = 1.7459e+10 p = 6.3026e+12 p = 2.2689e+15 p = 8.1454e+17 p = 2.9161e+20 p = 1.0410e+23 p = 3.7061e+25 p = 1.3157e+28 p = 4.6574e+30 p = 1.6441e+33 p = 5.7871e+35 p = 2.0313e+38 p = 7.1095e+40 p = 2.4812e+43 p = 8.6346e+45 p = 2.9962e+48 p = 1.0367e+51 p = 3.5766e+53 p = 1.2303e+56 p = 4.2201e+58 p = 1.4433e+61 p = 4.9215e+63 p = 1.6733e+66 p = 5.6726e+68 p = 1.9173e+71 p = 6.4614e+73 p = 2.1710e+76 p = 7.2730e+78 p = 2.4292e+81 p = 8.0891e+83 p = 2.6856e+86 p = 8.8893e+88 p = 2.9335e+91 p = 9.6511e+93 p = 3.1656e+96 p = 1.0351e+99 p = 3.3746e+101 p = 1.0967e+104 p = 3.5534e+106 p = 1.1478e+109 p = 3.6958e+111 p = 1.1863e+114 p = 3.7963e+116 p = 1.2110e+119 p = 3.8510e+121 p = 1.2208e+124 p = 3.8576e+126 p1 = 1.3021e+128 y = 0.9704

6   Pass
n = 100; y_correct = 1.0000; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 365 p = 132860 p = 48228180 p = 1.7459e+10 p = 6.3026e+12 p = 2.2689e+15 p = 8.1454e+17 p = 2.9161e+20 p = 1.0410e+23 p = 3.7061e+25 p = 1.3157e+28 p = 4.6574e+30 p = 1.6441e+33 p = 5.7871e+35 p = 2.0313e+38 p = 7.1095e+40 p = 2.4812e+43 p = 8.6346e+45 p = 2.9962e+48 p = 1.0367e+51 p = 3.5766e+53 p = 1.2303e+56 p = 4.2201e+58 p = 1.4433e+61 p = 4.9215e+63 p = 1.6733e+66 p = 5.6726e+68 p = 1.9173e+71 p = 6.4614e+73 p = 2.1710e+76 p = 7.2730e+78 p = 2.4292e+81 p = 8.0891e+83 p = 2.6856e+86 p = 8.8893e+88 p = 2.9335e+91 p = 9.6511e+93 p = 3.1656e+96 p = 1.0351e+99 p = 3.3746e+101 p = 1.0967e+104 p = 3.5534e+106 p = 1.1478e+109 p = 3.6958e+111 p = 1.1863e+114 p = 3.7963e+116 p = 1.2110e+119 p = 3.8510e+121 p = 1.2208e+124 p = 3.8576e+126 p = 1.2152e+129 p = 3.8156e+131 p = 1.1943e+134 p = 3.7262e+136 p = 1.1588e+139 p = 3.5924e+141 p = 1.1100e+144 p = 3.4190e+146 p = 1.0496e+149 p = 3.2118e+151 p = 9.7961e+153 p = 2.9780e+156 p = 9.0234e+158 p = 2.7251e+161 p = 8.2024e+163 p = 2.4607e+166 p = 7.3576e+168 p = 2.1926e+171 p = 6.5119e+173 p = 1.9275e+176 p = 5.6862e+178 p = 1.6717e+181 p = 4.8982e+183 p = 1.4303e+186 p = 4.1621e+188 p = 1.2070e+191 p = 3.4883e+193 p = 1.0046e+196 p = 2.8832e+198 p = 8.2461e+200 p = 2.3501e+203 p = 6.6744e+205 p = 1.8889e+208 p = 5.3266e+210 p = 1.4968e+213 p = 4.1909e+215 p = 1.1693e+218 p = 3.2506e+220 p = 9.0041e+222 p = 2.4851e+225 p = 6.8341e+227 p = 1.8725e+230 p = 5.1120e+232 p = 1.3905e+235 p = 3.7682e+237 p = 1.0174e+240 p = 2.7368e+242 p = 7.3347e+244 p = 1.9584e+247 p = 5.2093e+249 p1 = 1.6955e+256 y = 1.0000

7   Pass
n = 10 y_correct = 0.1169; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

n = 10 p = 1 p = 365 p = 132860 p = 48228180 p = 1.7459e+10 p = 6.3026e+12 p = 2.2689e+15 p = 8.1454e+17 p = 2.9161e+20 p = 1.0410e+23 p = 3.7061e+25 p1 = 4.1969e+25 y = 0.1169

8   Pass
n = 13 y_correct = 0.1944; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

n = 13 p = 1 p = 365 p = 132860 p = 48228180 p = 1.7459e+10 p = 6.3026e+12 p = 2.2689e+15 p = 8.1454e+17 p = 2.9161e+20 p = 1.0410e+23 p = 3.7061e+25 p = 1.3157e+28 p = 4.6574e+30 p = 1.6441e+33 p1 = 2.0408e+33 y = 0.1944

9   Pass
n = 2; y_correct = 1/365; assert(abs(birthday_prob(n)-y_correct) <= 0.015)

p = 1 p = 365 p = 132860 p1 = 133225 y = 0.0027