Cody

Problem 1272. The almost-birthday problem.

Solution 1770131

Submitted on 2 Apr 2019 by Abdelfatah Teamah
• Size: 8
• This is the leading solution.
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 = 10; d = 1; y_correct = 0.3147; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
n = 14; d = 1; y_correct = 0.5375; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
n = 20; d = 1; y_correct = 0.8045; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
n = 25; d = 1; y_correct = 0.9263; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

5   Pass
n = 30; d = 1; y_correct = 0.9782; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]

6   Pass
n = 35; d = 1; y_correct = 0.9950; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint6 (line 4) In solutionTest (line 13)]

7   Pass
n = 10; d = 2; y_correct = 0.4721; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint7 (line 4) In solutionTest (line 15)]

8   Pass
n = 14; d = 2; y_correct = 0.7305; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint8 (line 4) In solutionTest (line 17)]

9   Pass
n = 20; d = 2; y_correct = 0.9393; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint9 (line 4) In solutionTest (line 19)]

10   Pass
n = 25; d = 2; y_correct = 0.9890; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint10 (line 4) In solutionTest (line 21)]

11   Pass
n = 30; d = 2; y_correct = 0.9987; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint11 (line 4) In solutionTest (line 23)]

12   Pass
n = 10; d = 3; y_correct = 0.5965; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint12 (line 4) In solutionTest (line 25)]

13   Pass
n = 14; d = 3; y_correct = 0.8466; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint13 (line 4) In solutionTest (line 27)]

14   Pass
n = 20; d = 3; y_correct = 0.9826; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint14 (line 4) In solutionTest (line 29)]

15   Pass
n = 25; d = 3; y_correct = 0.9986; assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In almostBirthday (line 2) In ScoringEngineTestPoint15 (line 4) In solutionTest (line 31)]