Cody

Solution 1577156

Submitted on 6 Jul 2018 by laurent guyot
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))

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

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

temp = 31 17 13 7 5 temp = 11 7 3 2 temp = 17 7 5 3 2

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

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

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

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