Cody

Solution 1346599

Submitted on 16 Nov 2017 by margreet docter
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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num'},'FileName','top5primes.m')

2   Pass
x = 1:10; y_correct = [7 5 3 2 NaN]; assert(isequaln(top5primes(x),y_correct))

A = 0 2 3 0 5 0 7 0 0 0

3   Pass
x = (1:2:100).'; y_correct = [97 89 83 79 73].'; assert(isequaln(top5primes(x),y_correct))

A = 0 3 5 7 0 11 13 0 17 19 0 23 0 0 29 31 0 0 37 0 41 43 0 47 0 0 53 0 0 59 61 0 0 67 0 71 73 0 0 79 0 83 0 0 89 0 0 0 97 0

4   Pass
x = [17 6 3 13 8 17 1 2 5 5 3 7 7 11 2 31 7 6]; y_correct = [31 11 17 17 7 7 13 3 5 7 2 3 5 NaN 2]; assert(isequaln(top5primes(x),y_correct))

A = 17 0 3 13 0 17 0 2 5 5 3 7 7 11 2 31 7 0

5   Pass
x = interp1(magic(30).',1:5).'; y_correct = [877 733 863 719 881 829 701 751 173 769 797 139 59 157 29 89 107 43 109 13 73 NaN 11 61 NaN]; assert(isequaln(top5primes(x),y_correct))

A = 797 0 0 0 0 0 0 0 0 881 829 0 863 0 0 0 0 0 0 0 0 0 0 0 0 877 0 0 0 0 0 0 0 719 0 0 701 0 0 0 0 0 0 0 0 0 733 0 0 769 0 0 751 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 139 0 173 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 0 0 0 0 29 0 0 11 0 0 0 0 0 0 0 0 0 43 0 0 0 0 59 61 0 41 0 0 0 0 0 0 0 0 0 73 0 0 109 0 89 0 0 0 0 0 107 0 0 0 0 0 0 157 0

6   Pass
rng(0); x = reshape(randperm(200,180),36,5); y_correct = [163 181 173 197 193 71 179 149 191 157 23 167 113 139 151 19 131 101 83 137 NaN 109 67 73 127]; assert(isequaln(top5primes(x),y_correct))

A = 23 79 0 0 0 0 0 0 0 61 0 0 0 0 0 0 0 0 11 0 163 0 0 0 151 0 0 41 0 0 0 107 53 0 0 0 0 0 0 0 0 0 173 0 97 0 17 0 43 0 0 0 0 197 0 0 0 0 73 0 0 0 0 0 0 0 0 2 83 0 0 109 0 0 89 0 0 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 67 191 0 19 0 0 0 157 0 37 101 0 193 0 0 0 7 0 0 103 0 0 0 0 0 0 0 0 0 131 113 0 0 71 0 149 0 137 0 179 0 0 0 0 0 0 0 0 0 0 0 0 0 0 181 0 0 0 0 29 0 0 0 0 0 0 59 0 0 0 0 47 0 0 3 0 139 31 0 167 0 0 0 0 0 0 0 127