Cody

# Problem 109. Check if sorted

Solution 117410

Submitted on 23 Jul 2012 by pietro
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))

x = 1.0e-03 * Columns 1 through 6 0.0096 0.0007 0.0036 0.0021 0.0163 0.0032 Columns 7 through 12 0.0006 0.0166 0.0030 0.0011 0.0028 0.0166 Columns 13 through 18 0.0016 0.0361 0.0047 0.0024 0.0126 0.0187 Columns 19 through 24 0.0192 0.0119 0.0079 0.0017 0.0078 0.0060 Columns 25 through 30 0.0214 0.0122 0.0011 0.0052 0.0040 0.0046 Columns 31 through 36 0.0034 0.0023 0.0029 0.0006 0.0019 0.0201 Columns 37 through 42 0.0208 0.0036 0.0203 0.0018 0.0138 0.0101 Columns 43 through 48 0.0066 0.0004 0.0260 0.0065 0.0079 0.0144 Columns 49 through 54 0.0043 0.0079 0.0027 0.0049 0.0120 0.0300 Columns 55 through 60 0.0043 0.0181 0.0002 0.0007 0.0030 0.0296 Columns 61 through 66 0.0039 0.0060 0.0116 0.0092 0.0105 0.0121 Columns 67 through 72 0.0107 0.0157 0.0004 0.0118 0.0062 0.0045 Columns 73 through 78 0.0135 0.0010 0.0174 0.0077 0.0073 0.0225 Columns 79 through 84 0.0211 0.0100 0.0023 0.0058 0.0011 0.0142 Columns 85 through 90 0.0216 0.0014 0.0125 0.0031 0.0003 0.0018 Columns 91 through 96 0.0082 0.0342 0.0006 0.0139 0.0033 0.0229 Columns 97 through 102 0.0534 0.0419 0.0105 0.0038 0.0015 0.0002 Columns 103 through 108 0.0656 0.0023 0.0097 0.0113 0.0029 0.0111 Columns 109 through 114 0.0103 0.0272 0.0006 0.0027 0.0290 0.0172 Columns 115 through 120 0.0032 0.0276 0.0133 0.0188 0.0039 0.0020 Columns 121 through 126 0.0063 0.0092 0.0077 0.0011 0.0023 0.0056 Columns 127 through 132 0.0033 0.0021 0.0040 0.0000 0.0076 0.0184 Columns 133 through 138 0.0117 0.0237 0.0019 0.0063 0.0077 0.0116 Columns 139 through 144 0.0076 0.0002 0.0179 0.0076 0.0210 0.0050 Columns 145 through 150 0.0084 0.0115 0.0024 0.0023 0.0171 0.0007 Columns 151 through 156 0.0021 0.0023 0.0022 0.0027 0.0119 0.0128 Columns 157 through 162 0.0027 0.0034 0.0161 0.0045 0.0001 0.0021 Columns 163 through 168 0.0402 0.0088 0.0009 0.0058 0.0136 0.0270 Columns 169 through 174 0.0012 0.0158 0.0174 0.0117 0.0000 0.0089 Columns 175 through 180 0.0049 0.0082 0.0248 0.0022 0.0013 0.0101 Columns 181 through 186 0.0043 0.0067 0.0001 0.0166 0.0018 0.0173 Columns 187 through 192 0.0090 0.0045 0.0085 0.0053 0.0276 0.0086 Columns 193 through 198 0.0097 0.0228 0.0206 0.0074 0.0003 0.0173 Columns 199 through 204 0.0008 0.0058 0.0043 0.0020 0.0163 0.0183 Columns 205 through 210 0.0077 0.0032 0.0011 0.0039 0.0017 0.0042 Columns 211 through 216 0.0150 0.0199 0.0154 0.0185 0.0039 0.0141 Columns 217 through 222 0.0492 0.0156 0.0076 0.0030 0.0099 0.0019 Columns 223 through 228 0.0023 0.0032 0.0066 0.0037 0.0093 0.0032 Columns 229 through 234 0.0275 0.0071 0.0065 0.0201 0.0131 0.0097 Columns 235 through 240 0.0033 0.0011 0.0163 0.0030 0.0099 0.0000 Columns 241 through 246 0.0085 0.0220 0.0120 0.0198 0.0207 0.0005 Columns 247 through 252 0.0210 0.0123 0.0069 0.0011 0.0300 0.0005 Columns 253 through 258 0.0182 0.0067 0.0311 0.0252 0.0012 0.0201 Columns 259 through 264 0.0122 0.0010 0.0038 0.0257 0.0083 0.0087 Columns 265 through 270 0.0261 0.0000 0.0102 0.0012 0.0108 0.0303 Columns 271 through 276 0.0004 0.0125 0.0472 0.0122 0.0065 0.0031 Columns 277 through 282 0.0026 0.0050 0.0213 0.0156 0.0043 0.0002 Columns 283 through 288 0.0454 0.0039 0.0115 0.0007 0.0095 0.0032 Columns 289 through 294 0.0487 0.0162 0.0066 0.0029 0.0074 0.0202 Columns 295 through 300 0.0167 0.0035 0.0266 0.0018 0.0245 0.0046 Columns 301 through 306 0.0043 0.0154 0.0007 0.0033 0.0027 0.0063 Columns 307 through 312 0.0133 0.0113 0.0126 0.0264 0.0278 0.0001 Columns 313 through 318 0.0046 0.0012 0.0099 0.0004 0.0010 0.0165 Columns 319 through 324 0.0147 0.0042 0.0003 0.0038 0.0138 0.0522 Columns 325 through 330 0.0038 0.0228 0.0082 0.0086 0.0212 0.0109 Columns 331 through 336 0.0251 0.0162 0.0169 0.0031 0.0048 0.0087 Columns 337 through 342 0.0044 0.0047 0.0148 0.0143 0.0216 0.0062 Columns 343 through 348 0.0103 0.0107 0.0002 0.0059 0.0064 0.0048 Columns 349 through 354 0.0037 0.0055 0.0030 0.0004 0.0053 0.0018 Columns 355 through 360 0.0043 0.0100 0.0006 0.0017 0.0007 0.0160 Columns 361 through 366 0.0048 0.0370 0.0078 0.0151 0.0018 0.0039 Columns 367 through 372 0.0060 0.0163 0.0144 0.0061 0.0096 0.0146 Columns 373 through 378 0.0038 0.0076 0.0001 0.0128 0.0096 0.0007 Columns 379 through 384 0.0045 0.0189 0.0122 0.0042 0.0175 0.0122 Columns 385 through 390 0.0189 0.0111 0.0250 0.0013 0.0215 0.0048 Columns 391 through 396 0.0169 0.0103 0.0168 0.0010 0.0254 0.0134 Columns 397 through 402 0.0094 0.0009 0.0439 0.0060 0.0044 0.0007 Columns 403 through 408 0.0100 0.0014 0.0377 0.0112 0.0249 0.0025 Columns 409 through 414 0.0049 0.0150 0.0155 0.0162 0.0027 0.0046 Columns 415 through 420 0.0438 0.0188 0.0062 0.0085 0.0099 0.0030 Columns 421 through 426 0.0190 0.0198 0.0001 0.0068 0.0042 0.0088 Columns 427 through 432 0.0015 0.0102 0.0016 0.0004 0.0211 0.0031 Columns 433 through 438 0.0002 0.0347 0.0002 0.0025 0.0027 0.0038 Columns 439 through 444 0.0084 0.0172 0.0010 0.0224 0.0145 0.0106 Columns 445 through 450 0.0068 0.0155 0.0106 0.0068 0.0010 0.0248 Columns 451 through 456 0.0299 0.0475 0.0072 0.0118 0.0021 0.0080 Columns 457 through 462 0.0271 0.0004 0.0030 0.0130 0.0127 0.0062 Columns 463 through 468 0.0203 0.0047 0.0099 0.0257 0.0141 0.0206 Columns 469 through 474 0.0080 0.0041 0.0035 0.0087 0.0049 0.0264 Columns 475 through 480 0.0070 0.0065 0.0120 0.0170 0.0032 0.0014 Columns 481 through 486 0.0101 0.0040 0.0019 0.0002 0.0064 0.0056 Columns 487 through 492 0.0098 0.0043 0.0055 0.0211 0.0109 0.0118 Columns 493 through 498 0.0068 0.0001 0.0181 0.0036 0.0006 0.0064 Columns 499 through 504 0.0064 0.0090 0.0196 0.0140 0.0172 0.0002 Columns 505 through 510 0.0089 0.0010 0.0384 0.0060 0.0078 0.0051 Columns 511 through 516 0.0080 0.0114 0.0130 0.0365 0.0170 0.0312 Columns 517 through 522 0.0152 0.0024 0.0205 0.0154 0.0114 0.0149 Columns 523 through 528 0.0050 0.0001 0.0021 0.0153 0.0047 0.0031 Columns 529 through 534 0.0000 0.0082 0.0166 0.0010 0.0007 0.0122 Columns 535 through 540 0.0019 0.0049 0.0104 0.0003 0.0198 0.0394 Columns 541 through 546 0.0081 0.0029 0.0069 0.0078 0.0088 0.0018 Columns 547 through 552 0.0217 0.0006 0.0011 0.0053 0.0119 0.0082 Columns 553 through 558 0.0136 0.0207 0.0034 0.0127 0.0012 0.0103 Columns 559 through 564 0.0226 0.0017 0.0103 0.0016 0.0027 0.0289 Columns 565 through 570 0.0020 0.0004 0.0023 0.0190 0.0097 0.0020 Columns 571 through 576 0.0023 0.0166 0.0064 0.0121 0.0119 0.0012 Columns 577 through 582 0.0004 0.0373 0.0027 0.0045 0.0184 0.0126 Columns 583 through 588 0.0135 0.0071 0.0015 0.0064 0.0039 0.0043 Columns 589 through 594 0.0095 0.0128 0.0010 0.0124 0.0109 0.0263 Columns 595 through 600 0.0008 0.0057 0.0167 0.0039 0.0014 0.0030 Columns 601 through 606 0.0026 0.0020 0.0144 0.0019 0.0004 0.0305 Columns 607 through 612 0.0060 0.0466 0.0182 0.0056 0.0014 0.0315 Columns 613 through 618 0.0112 0.0080 0.0111 0.0001 0.0019 0.0020 Columns 619 through 624 0.0353 0.0060 0.0061 0.0011 0.0287 0.0223 Columns 625 through 630 0.0107 0.0282 0.0120 0.0000 0.0093 0.0022 Columns 631 through 636 0.0301 0.0163 0.0036 0.0080 0.0111 0.0000 Columns 637 through 642 0.0050 0.0181 0.0115 0.0291 0.0047 0.0008 Columns 643 through 648 0.0064 0.0030 0.0064 0.0102 0.0132 0.0082 Columns 649 through 654 0.0067 0.0090 0.0034 0.0086 0.0950 0.0033 Columns 655 through 660 0.0048 0.0152 0.0122 0.0156 0.0105 0.0044 Columns 661 through 666 0.0006 0.0141 0.0028 0.0148 0.0023 0.0027 Columns 667 through 672 0.0011 0.0134 0.0027 0.0011 0.0096 0.0074 Columns 673 through 678 0.0072 0.0005 0.0034 0.0064 0.0105 0.0082 Columns 679 through 684 0.0097 0.0023 0.0069 0.0120 0.0056 0.0441 Columns 685 through 690 0.0025 0.0083 0.0035 0.0051 0.0176 0.0063 Columns 691...

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

x = 4 -1 -1 5 -1 -4 y = 0