Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 204315

Submitted on 15 Feb 2013 by @bmtran

Correct

40Size
Leading solution size is 25.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
n = 10;
d = 1;
y_correct = 0.3147;
assert(abs(almostBirthday(n,d)-y_correct) <= 0.0001)

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

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

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

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

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

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

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

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

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

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

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

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

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

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