Cody

Solution 1317607

Submitted on 27 Oct 2017 by Matt Tearle
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))

x = 10 9 8 7 6 5 4 3 2 1

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

x = 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1

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

x = 31 11 17 17 8 7 13 7 6 7 6 5 5 3 3 1 2 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))

x = 893 894 895 896 897 877 878 879 880 881 861 862 863 864 865 845 846 847 848 849 829 830 831 832 833 813 814 815 816 817 797 798 799 800 801 781 782 783 784 785 780 766 767 768 769 764 765 751 752 753 748 749 750 736 737 732 733 734 735 721 716 717 718 719 720 700 701 702 703 704 684 685 686 687 688 218 219 220 221 222 202 203 204 205 206 186 187 188 189 190 170 171 172 173 174 154 155 156 157 158 138 139 140 141 142 122 123 124 125 126 106 107 108 109 110 105 91 92 93 94 89 90 76 77 78 73 74 75 61 62 57 58 59 60 46 41 42 43 44 45 25 26 27 28 29 9 10 11 12 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))

x = 200 188 196 197 194 198 184 192 195 193 187 182 183 191 190 186 181 175 180 185 178 179 173 177 176 172 167 168 171 160 170 154 166 152 157 169 142 161 144 151 164 131 159 143 137 163 130 156 139 136 162 126 150 124 128 155 115 149 120 127 147 112 148 116 121 140 111 146 114 118 133 109 141 110 117 132 107 135 95 108 129 103 113 87 102 125 99 106 83 98 122 79 101 82 97 119 78 86 73 93 104 76 85 66 91 100 72 80 65 90 96 69 77 60 89 94 64 68 59 75 88 62 67 58 74 81 51 53 49 70 71 44 50 47 63 57 39 41 46 61 55 38 35 45 56 52 37 33 43 36 27 30 24 40 34 26 29 16 20 31 23 18 10 12 28 19 17 9 11 25 15 6 4 7 21 14 3 2 1 13