Cody

# Problem 109. Check if sorted

Solution 231809

Submitted on 17 Apr 2013 by Martin
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))

``` g = Columns 1 through 10 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0001 0.0001 0.0001 Columns 11 through 20 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0002 Columns 21 through 30 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 Columns 31 through 40 0.0002 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 Columns 41 through 50 0.0004 0.0004 0.0004 0.0004 0.0004 0.0004 0.0004 0.0004 0.0004 0.0005 Columns 51 through 60 0.0005 0.0005 0.0005 0.0005 0.0005 0.0006 0.0006 0.0006 0.0006 0.0006 Columns 61 through 70 0.0006 0.0006 0.0006 0.0006 0.0006 0.0007 0.0007 0.0007 0.0007 0.0007 Columns 71 through 80 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0008 0.0008 0.0008 Columns 81 through 90 0.0008 0.0008 0.0008 0.0008 0.0009 0.0009 0.0009 0.0009 0.0010 0.0010 Columns 91 through 100 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 Columns 101 through 110 0.0010 0.0010 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 Columns 111 through 120 0.0011 0.0011 0.0011 0.0011 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 Columns 121 through 130 0.0012 0.0012 0.0012 0.0012 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 Columns 131 through 140 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0014 Columns 141 through 150 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 0.0015 0.0015 0.0015 0.0015 Columns 151 through 160 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0016 0.0016 Columns 161 through 170 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 Columns 171 through 180 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 Columns 181 through 190 0.0017 0.0017 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 Columns 191 through 200 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0019 0.0019 0.0019 0.0019 Columns 201 through 210 0.0019 0.0019 0.0019 0.0019 0.0019 0.0020 0.0020 0.0020 0.0020 0.0020 Columns 211 through 220 0.0021 0.0021 0.0021 0.0021 0.0021 0.0021 0.0022 0.0022 0.0022 0.0022 Columns 221 through 230 0.0022 0.0022 0.0022 0.0022 0.0023 0.0023 0.0023 0.0023 0.0023 0.0023 Columns 231 through 240 0.0023 0.0023 0.0023 0.0023 0.0024 0.0024 0.0024 0.0024 0.0024 0.0024 Columns 241 through 250 0.0024 0.0024 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 Columns 251 through 260 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0026 0.0026 Columns 261 through 270 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0027 0.0027 0.0027 Columns 271 through 280 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0028 0.0028 0.0028 Columns 281 through 290 0.0028 0.0028 0.0028 0.0028 0.0028 0.0028 0.0028 0.0029 0.0029 0.0029 Columns 291 through 300 0.0029 0.0029 0.0029 0.0029 0.0029 0.0029 0.0029 0.0030 0.0030 0.0030 Columns 301 through 310 0.0030 0.0030 0.0030 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 Columns 311 through 320 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0032 0.0032 0.0032 Columns 321 through 330 0.0032 0.0032 0.0032 0.0032 0.0032 0.0033 0.0033 0.0033 0.0033 0.0033 Columns 331 through 340 0.0033 0.0033 0.0033 0.0033 0.0033 0.0033 0.0034 0.0034 0.0034 0.0034 Columns 341 through 350 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0035 0.0035 0.0035 0.0035 Columns 351 through 360 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 Columns 361 through 370 0.0036 0.0036 0.0037 0.0037 0.0037 0.0037 0.0037 0.0038 0.0038 0.0038 Columns 371 through 380 0.0038 0.0038 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 Columns 381 through 390 0.0039 0.0039 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0040 0.0041 Columns 391 through 400 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 Columns 401 through 410 0.0041 0.0042 0.0042 0.0042 0.0042 0.0043 0.0043 0.0043 0.0043 0.0043 Columns 411 through 420 0.0043 0.0043 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 Columns 421 through 430 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0045 0.0045 0.0045 0.0045 Columns 431 through 440 0.0045 0.0045 0.0045 0.0045 0.0045 0.0046 0.0046 0.0046 0.0046 0.0046 Columns 441 through 450 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 Columns 451 through 460 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 Columns 461 through 470 0.0047 0.0047 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 Columns 471 through 480 0.0048 0.0049 0.0049 0.0049 0.0049 0.0049 0.0049 0.0049 0.0049 0.0049 Columns 481 through 490 0.0049 0.0049 0.0049 0.0049 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 Columns 491 through 500 0.0050 0.0050 0.0050 0.0050 0.0050 0.0051 0.0051 0.0051 0.0051 0.0051 Columns 501 through 510 0.0051 0.0051 0.0051 0.0051 0.0051 0.0051 0.0052 0.0052 0.0052 0.0052 Columns 511 through 520 0.0052 0.0052 0.0052 0.0052 0.0053 0.0053 0.0053 0.0053 0.0053 0.0053 Columns 521 through 530 0.0053 0.0053 0.0053 0.0054 0.0054 0.0054 0.0054 0.0054 0.0054 0.0054 Columns 531 through 540 0.0054 0.0054 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 Columns 541 through 550 0.0055 0.0056 0.0056 0.0056 0.0056 0.0056 0.0056 0.0056 0.0056 0.0056 Columns 551 through 560 0.0056 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 Columns 561 through 570 0.0057 0.0057 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 Columns 571 through 580 0.0058 0.0058 0.0059 0.0059 0.0059 0.0059 0.0059 0.0059 0.0059 0.0059 Columns 581 through 590 0.0059 0.0059 0.0059 0.0059 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 Columns 591 through 600 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0061 Columns 601 through 610 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0062 0.0062 Columns 611 through 620 0.0062 0.0062 0.0062 0.0062 0.0062 0.0062 0.0062 0.0062 0.0062 0.0062 Columns 621 through 630 0.0062 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0064 0.0064 Columns 631 through 640 0.0064 0.0064 0.0064 0.0064 0.0064 0.0064 0.0064 0.0064 0.0064 0.0065 Columns 641 through 650 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 Columns 651 through 660 0.0065 0.0065 0.0066 0.0066 0.0066 0.0066 0.0066 0.0066 0.0066 0.0066 Columns 661 through 670 0.0066 0.0067 0.0067 0.0067 0.0067 0.0067 0.0067 0.0067 0.0068 0.0068 Columns 671 through 680 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 Columns 681 through 690 0.0068 0.0068 0.0068 0.0068 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 Columns 691 through 700 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0070 0.0070 0.0070 Columns 701 through 710 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0071 0.0071 0.0071 0.0071 Columns 711 through 720 0.0071 0.0071 0.0071 0.0071 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 Columns 721 through 730 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0073 0.0073 0.0073 0.0073 Columns 731 through 740 0.0073 0.0073 0.0073 0.0073 0.0073 0.0073 0.0073 0.0073 0.0074 0.0074 Columns 741 through 750 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 Columns 751 through 760 0.0074 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 Columns 761 through 770 0.0076 0.0076 0.0076 0.0076 0.0076 0.0076 0.0076 0.0076 0.0076 0.0076 Columns 771 through 780 0.0077 0.0077 0.0077 0.0078 0.0078 0.0078 0.0078 0.0078 0.0078 0.0078 Columns 781 through 790 0.0078 0.0078 0.0078 0.0078 0.0079 0.0079 0.0079 0.0079 ...```

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

``` g = 1 3 3 4 5 7 8 ```