Cody

# Problem 44309. Pi Digit Probability

Solution 1919015

Submitted on 2 Sep 2019 by Virtual AS
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 = 101; n = 3; y_correct = 0.1200; assert(abs(pidigit(N,n)-y_correct)<0.0001) assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\d\.\+\-\*\/]+','match')))) % modified from the comment of Alfonso on https://www.mathworks.com/matlabcentral/cody/problems/44343

[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 pidigit (line 2) In ScoringEngineTestPoint1 (line 4) In solutionTest (line 3)]

2   Pass
N = 201; n = 6; y_correct = 0.0750; assert(abs(pidigit(N,n)-y_correct)<0.0001) assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\d\.\+\-\*\/]+','match'))))

[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 pidigit (line 2) In ScoringEngineTestPoint2 (line 4) In solutionTest (line 5)]

3   Pass
N = 202; n = 6; y_correct = 0.0796; assert(abs(pidigit(N,n)-y_correct)<0.0001) assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\d\.\+\-\*\/]+','match'))))

[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 pidigit (line 2) In ScoringEngineTestPoint3 (line 4) In solutionTest (line 7)]

4   Pass
N = 203; n = 6; y_correct = 0.0792; assert(abs(pidigit(N,n)-y_correct)<0.0001) assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\d\.\+\-\*\/]+','match'))))

[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 pidigit (line 2) In ScoringEngineTestPoint4 (line 4) In solutionTest (line 9)]

5   Pass
N = 1001; n = 9; y_correct = 0.1050; assert(abs(pidigit(N,n)-y_correct)<0.0001) assert(~any(cellfun(@(x)ismember(max([0,str2num(x)]),[101,201,202,203,1001]),regexp(fileread('pidigit.m'),'[\d\.\+\-\*\/]+','match'))))

[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 pidigit (line 2) In ScoringEngineTestPoint5 (line 4) In solutionTest (line 11)]