Cody

# Problem 109. Check if sorted

Solution 1820212

Submitted on 20 May 2019 by Aryeh Samoka
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
x = sort(rand(1,10^5)); y_correct = 1; assert(isequal(sortok(x),y_correct))

S = 1.0e-03 * Columns 1 through 18 0.0027 0.0060 0.0129 0.0031 0.0011 0.0022 0.0168 0.0110 0.0097 0.0092 0.0034 0.0317 0.0032 0.0053 0.0120 0.0353 0.0100 0.0066 Columns 19 through 36 0.0067 0.0084 0.0099 0.0069 0.0167 0.0031 0.0189 0.0062 0.0245 0.0206 0.0129 0.0080 0.0057 0.0019 0.0002 0.0008 0.0383 0.0162 Columns 37 through 54 0.0022 0.0516 0.0068 0.0004 0.0000 0.0307 0.0002 0.0569 0.0231 0.0179 0.0066 0.0111 0.0030 0.0030 0.0131 0.0166 0.0004 0.0009 Columns 55 through 72 0.0011 0.0032 0.0333 0.0286 0.0001 0.0083 0.0001 0.0003 0.0006 0.0120 0.0114 0.0099 0.0181 0.0019 0.0025 0.0014 0.0002 0.0020 Columns 73 through 90 0.0203 0.0266 0.0053 0.0117 0.0044 0.0214 0.0000 0.0064 0.0163 0.0003 0.0125 0.0017 0.0035 0.0173 0.0049 0.0028 0.0196 0.0141 Columns 91 through 108 0.0283 0.0542 0.0021 0.0023 0.0000 0.0399 0.0006 0.0005 0.0041 0.0021 0.0077 0.0023 0.0235 0.0348 0.0100 0.0031 0.0104 0.0061 Columns 109 through 126 0.0199 0.0019 0.0028 0.0460 0.0070 0.0143 0.0067 0.0018 0.0269 0.0069 0.0058 0.0061 0.0017 0.0010 0.0070 0.0059 0.0054 0.0230 Columns 127 through 144 0.0373 0.0035 0.0027 0.0161 0.0024 0.0143 0.0190 0.0419 0.0012 0.0261 0.0104 0.0059 0.0100 0.0027 0.0103 0.0242 0.0121 0.0024 Columns 145 through 162 0.0008 0.0042 0.0020 0.0157 0.0028 0.0030 0.0059 0.0029 0.0063 0.0065 0.0173 0.0025 0.0069 0.0062 0.0175 0.0053 0.0055 0.0201 Columns 163 through 180 0.0127 0.0064 0.0224 0.0037 0.0022 0.0100 0.0080 0.0029 0.0032 0.0004 0.0099 0.0069 0.0087 0.0028 0.0231 0.0017 0.0029 0.0076 Columns 181 through 198 0.0106 0.0056 0.0057 0.0000 0.0014 0.0391 0.0228 0.0613 0.0050 0.0155 0.0014 0.0049 0.0143 0.0115 0.0000 0.0015 0.0496 0.0064 Columns 199 through 216 0.0075 0.0001 0.0062 0.0069 0.0064 0.0070 0.0264 0.0065 0.0002 0.0138 0.0253 0.0142 0.0088 0.0039 0.0174 0.0028 0.0085 0.0013 Columns 217 through 234 0.0044 0.0366 0.0007 0.0083 0.0030 0.0038 0.0116 0.0127 0.0005 0.0024 0.0002 0.0221 0.0079 0.0026 0.0069 0.0007 0.0022 0.0234 Columns 235 through 252 0.0060 0.0062 0.0160 0.0059 0.0349 0.0052 0.0033 0.0136 0.0079 0.0024 0.0030 0.0024 0.0037 0.0037 0.0020 0.0108 0.0083 0.0047 Columns 253 through 270 0.0011 0.0058 0.0029 0.0017 0.0070 0.0022 0.0036 0.0064 0.0049 0.0024 0.0051 0.0072 0.0373 0.0019 0.0071 0.0028 0.0080 0.0088 Columns 271 through 288 0.0530 0.0018 0.0081 0.0090 0.0018 0.0044 0.0039 0.0321 0.0001 0.0220 0.0076 0.0182 0.0031 0.0094 0.0118 0.0038 0.0027 0.0059 Columns 289 through 306 0.0088 0.0153 0.0063 0.0003 0.0038 0.0025 0.0069 0.0121 0.0098 0.0019 0.0055 0.0122 0.0105 0.0111 0.0032 0.0043 0.0021 0.0073 Columns 307 through 324 0.0049 0.0010 0.0106 0.0000 0.0195 0.0085 0.0125 0.0041 0.0274 0.0321 0.0048 0.0093 0.0005 0.0006 0.0069 0.0078 0.0003 0.0318 Columns 325 through 342 0.0022 0.0088 0.0338 0.0018 0.0150 0.0130 0.0180 0.0036 0.0255 0.0002 0.0067 0.0020 0.0226 0.0106 0.0145 0.0220 0.0029 0.0084 Columns 343 through 360 0.0323 0.0067 0.0155 0.0042 0.0120 0.0075 0.0033 0.0037 0.0008 0.0056 0.0097 0.0288 0.0101 0.0017 0.0022 0.0067 0.0020 0.0018 Columns 361 through 378 0.0046 0.0092 0.0189 0.0044 0.0175 0.0008 0.0010 0.0199 0.0191 0.0014 0.0053 0.0012 0.0089 0.0001 0.0046 0.0349 0.0041 0.0111 Columns 379 through 396 0.0090 0.0010 0.0147 0.0017 0.0005 0.0102 0.0093 0.0096 0.0067 0.0066 0.0067 0.0164 0.0097 0.0035 0.0205 0.0114 0.0023 0.0005 Columns 397 through 414 0.0189 0.0404 0.0057 0.0019 0.0000 0.0100 0.0095 0.0189 0.0007 0.0148 0.0075 0.0042 0.0051 0.0026 0.0052 0.0064 0.0201 0.0024 Columns 415 through 432 0.0093 0.0043 0.0034 0.0062 0.0004 0.0060 0.0030 0.0023 0.0019 0.0168 0.0401 0.0123 0.0006 0.0170 0.0044 0.0080 0.0072 0.0389 Columns 433 through 450 0.0154 0.0223 0.0192 0.0449 0.0062 0.0169 0.0010 0.0008 0.0159 0.0041 0.0089 0.0392 0.0016 0.0115 0.0285 0.0215 0.0060 0.0085 Columns 451 through 468 0.0048 0.0194 0.0063 0.0022 0.0032 0.0039 0.0140 0.0055 0.0004 0.0020 0.0085 0.0179 0.0054 0.0097 0.0086 0.0467 0.0157 0.0184 Columns 469 through 486 0.0060 0.0050 0.0122 0.0091 0.0031 0.0035 0.0299 0.0175 0.0048 0.0020 0.0234 0.0023 0.0033 0.0087 0.0202 0.0248 0.0231 0.0005 Columns 487 through 504 0.0006 0.0221 0.0133 0.0002 0.0118 0.0037 0.0123 0.0018 0.0215 0.0196 0.0016 0.0182 0.0013 0.0083 0.0077 0.0125 0.0106 0.0032 Columns 505 through 522 0.0094 0.0020 0.0066 0.0178 0.0060 0.0100 0.0170 0.0079 0.0179 0.0206 0.0090 0.0056 0.0181 0.0023 0.0027 0.0045 0.0011 0.0065 Columns 523 through 540 0.0157 0.0165 0.0005 0.0080 0.0072 0.0067 0.0192 0.0068 0.0093 0.0017 0.0013 0.0036 0.0104 0.0302 0.0026 0.0138 0.0051 0.0045 Columns 541 through 558 0.0030 0.0097 0.0019 0.0019 0.0007 0.0013 0.0095 0.0036 0.0062 0.0406 0.0016 0.0111 0.0041 0.0129 0.0064 0.0262 0.0027 0.0009 Columns 559 through 576 0.0064 0.0018 0.0089 0.0090 0.0031 0.0131 0.0021 0.0106 0.0042 0.0029 0.0104 0.0038 0.0071 0.0198 0.0227 0.0395 0.0137 0.0060 Columns 577 through 594 0.0072 0.0003 0.0063 0.0013 0.0383 0.0016 0.0777 0.0143 0.0328 0.0357 0.0079 0.0107 0.0148 0.0011 0.0189 0.0094 0.0004 0.0120 Columns 595 through 612 0.0001 0.0049 0.0204 0.0037 0.0041 0.0122 0.0028 0.0061 0.0084 0.0017 0.0071 0.0225 0.0033 0.0027 0.0146 0.0044 0.0099 0.0019 Columns 613 through 630 0.0066 0.0050 0.0015 0.0013 0.0042 0.0057 0.0224 0.0020 0.0153 0.0052 0.0095 0.0145 0.0102 0.0079 0.0078 0.0048 0.0112 0.0177 Columns 631 through 648 0.0102 0.0039 0.0058 0.0188 0.0000 0.0272 0.0267 0.0034 0.0241 0.0174 0.0016 0.0116 0.0021 0.0018 0.0441 0.0082 0.0426 0.0071 Columns 649 through 666 0.0140 0.0059 0.0193 0.0055 0.0046 0.0045 0.0031 0.0013 0.0006 0.0008 0.0002 0.0299 0.0013 0.0142 0.0138 0.0012 0.0031 0.0027 Columns 667 through 684 0.0235 0.0049 0.0188 0.0099 0.0173 0.0000 0.0152 0.0069 0.0036 0.0504 0.0001 0.0255 0.0018 0.0117 0.0047 0.0137 0.0142 0.0054 Columns 685 through 702 0.0132 0.0286 0.0006 0.0018 0.0004 0.0137 0.0262 0.0417 0.0048 0.0091 0.0123 0.0160 0.0013 0.0118 0.0133 0.0021 0.0040 0.0028 Columns 703 through 720 0.0077 0.0130 0.0089 0.0113 0.0109 0.0140 0.0008 0.0135 0.0057 0.0059 0.0005 0.0361 0.0186 0.0206 0.0216 0.0015 0.0069 0.0023 Columns 721 through 738 0.0054 0.0052 0.0052 0.0023 0.0006 0.0073 0.0080 0.0112 0.0328 0.0011 0.0202 0.0040 0.0020 0.0070 0.0091 0.0030 0.0227 0.0104 Columns 739 through 756 0.0196 0.0184 0.0023 0.0032 0.0133 0.0121 0.0386 0.0309 0.0049 0.0390 0.0190 0.0071 0.0225 0.0047 0.0291 0.0025 0.0213 0.0066 Columns 757 through 774 0.0062 0.0315 0.0023 0.0099 0.0224 0.0035 0.0010 0.0085 0.0010 0.0049 0.0031 0.0403 0.0143 0.0029 0.0077 0.0036 0.0133 0.0066 Columns 775 through 792 0.0083 0.0088 0.0215 0.0274 0.0103 0.0272 0.0004 0.0026 0.0054 0.0008 0.0253 0.0032 0.0322 0.0128 0.0163 0.0039 0.0158 0.0252 Columns 793 through 810 0.0056 0.0186 0.0023 0.0025 0.0009 0.0098 0.0009 0.0361 0.0135 0.0054 0.0034 0.0081 0.0004 0.0013 0.0286 0.0051 0.0074 0.0039 Columns 811 through 828 0.0260 0.0011 0.0042 0.0058 0.0403 0.0015 0.0005 0.0276 0.0007 0.0056 0.0028 0.0020 0.0012 0.0059 0.0101 0.0018 0.0155 0.0019 Columns 829 through 846 0.0102 0.0112 0.0056 0.0530 0.0017 0.0055 0.0319 0.0108 0.0054 0.0037 0.0077 0.0106 0.0263 0.0148 0.0023 0.0009 0.0122 0.0038 Columns 847 through 864 0.0038 0.0086 0.0046 0.0036 0.0020 0.0014 0.0196 0.0125 0.0004 0.0033 0.0011 0.0045 0.0055 0.0034 ...

2   Pass
x = [1 5 4 3 8 7 3]; y_correct = 0; assert(isequal(sortok(x),y_correct))

S = 4 -1 -1 5 -1 -4