Cody

Solution 1945009

Submitted on 21 Sep 2019 by Tung Nguyen
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

c = 1 10 16 18 25 26 28 44 47 65 87 92 y = 0.1200

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'))))

c = 8 21 23 42 70 73 76 83 99 109 118 119 128 182 185 y = 0.0750

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'))))

c = 8 21 23 42 70 73 76 83 99 109 118 119 128 182 185 201 y = 0.0796

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'))))

c = 8 21 23 42 70 73 76 83 99 109 118 119 128 182 185 201 y = 0.0792

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'))))

c = Columns 1 through 30 6 13 15 31 39 43 45 46 56 59 63 80 81 101 123 130 145 170 181 188 191 194 200 209 215 248 250 260 285 295 Columns 31 through 60 329 332 337 342 354 357 389 392 400 415 417 419 423 434 441 460 461 466 483 488 497 499 502 528 530 534 543 550 554 565 Columns 61 through 90 573 595 637 640 659 665 676 687 691 694 698 706 707 715 719 733 739 748 749 763 764 765 766 767 768 773 778 779 784 795 Columns 91 through 105 801 808 815 845 895 903 909 925 942 947 977 987 989 991 999 y = 0.1050

Suggested Problems

More from this Author57