Cody

# Problem 109. Check if sorted

Solution 785611

Submitted on 29 Nov 2015 by Nikolaos Nikolaou
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))

p = Columns 1 through 17 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0001 0.0002 0.0002 0.0002 0.0002 0.0002 Columns 18 through 34 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0002 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0003 0.0004 Columns 35 through 51 0.0004 0.0004 0.0004 0.0004 0.0004 0.0004 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005 0.0005 0.0006 0.0006 0.0006 Columns 52 through 68 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0006 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 0.0007 Columns 69 through 85 0.0007 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0008 0.0009 0.0009 0.0009 0.0009 Columns 86 through 102 0.0009 0.0009 0.0009 0.0009 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0011 0.0011 Columns 103 through 119 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 Columns 120 through 136 0.0012 0.0012 0.0012 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0014 0.0014 0.0014 0.0014 0.0014 Columns 137 through 153 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0016 Columns 154 through 170 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0017 0.0017 0.0017 0.0017 0.0017 Columns 171 through 187 0.0017 0.0017 0.0017 0.0017 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0019 0.0019 0.0019 Columns 188 through 204 0.0019 0.0019 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0021 0.0021 0.0021 0.0021 0.0021 0.0021 Columns 205 through 221 0.0021 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.0023 0.0023 0.0023 0.0023 0.0023 0.0023 Columns 222 through 238 0.0024 0.0024 0.0024 0.0024 0.0024 0.0024 0.0024 0.0024 0.0024 0.0024 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 Columns 239 through 255 0.0025 0.0025 0.0025 0.0025 0.0025 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 0.0026 Columns 256 through 272 0.0026 0.0026 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 Columns 273 through 289 0.0028 0.0028 0.0028 0.0028 0.0028 0.0028 0.0028 0.0028 0.0028 0.0029 0.0029 0.0029 0.0029 0.0029 0.0029 0.0029 0.0029 Columns 290 through 306 0.0029 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0030 0.0031 0.0031 Columns 307 through 323 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0032 0.0032 0.0032 0.0032 0.0032 0.0032 0.0032 0.0032 Columns 324 through 340 0.0032 0.0032 0.0032 0.0032 0.0032 0.0032 0.0033 0.0033 0.0033 0.0033 0.0033 0.0033 0.0033 0.0033 0.0033 0.0033 0.0034 Columns 341 through 357 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0034 0.0035 0.0035 0.0035 0.0035 0.0035 0.0035 Columns 358 through 374 0.0035 0.0035 0.0035 0.0035 0.0035 0.0035 0.0035 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0036 0.0037 Columns 375 through 391 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0038 0.0038 0.0038 0.0038 0.0038 0.0038 0.0038 0.0038 0.0038 0.0038 Columns 392 through 408 0.0038 0.0038 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0039 0.0040 0.0040 0.0040 0.0040 0.0040 Columns 409 through 425 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0041 0.0042 0.0042 0.0042 0.0042 0.0042 0.0042 0.0042 Columns 426 through 442 0.0042 0.0042 0.0042 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 0.0043 Columns 443 through 459 0.0043 0.0043 0.0043 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0044 0.0045 0.0045 0.0045 Columns 460 through 476 0.0045 0.0045 0.0045 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0046 0.0047 0.0047 0.0047 0.0047 Columns 477 through 493 0.0047 0.0047 0.0047 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0049 0.0049 0.0049 0.0049 Columns 494 through 510 0.0049 0.0049 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0050 0.0051 0.0051 0.0051 0.0051 0.0051 0.0051 0.0051 Columns 511 through 527 0.0051 0.0051 0.0051 0.0051 0.0051 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0052 0.0053 0.0053 0.0053 Columns 528 through 544 0.0053 0.0053 0.0053 0.0053 0.0053 0.0053 0.0053 0.0053 0.0053 0.0054 0.0054 0.0054 0.0054 0.0054 0.0054 0.0054 0.0054 Columns 545 through 561 0.0054 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0055 0.0056 0.0056 0.0056 0.0056 0.0056 0.0056 Columns 562 through 578 0.0056 0.0056 0.0056 0.0056 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0057 0.0058 Columns 579 through 595 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 0.0058 0.0059 0.0059 0.0059 0.0059 0.0059 0.0059 0.0059 0.0059 Columns 596 through 612 0.0059 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0060 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 Columns 613 through 629 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0061 0.0062 0.0062 0.0062 0.0062 0.0062 0.0062 0.0063 0.0063 Columns 630 through 646 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0063 0.0064 0.0064 0.0064 0.0064 0.0065 0.0065 0.0065 Columns 647 through 663 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0065 0.0066 0.0066 0.0066 0.0066 0.0066 0.0067 0.0067 Columns 664 through 680 0.0067 0.0067 0.0067 0.0067 0.0067 0.0067 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 0.0068 Columns 681 through 697 0.0068 0.0068 0.0068 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0069 0.0070 0.0070 Columns 698 through 714 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0070 0.0071 0.0071 0.0071 0.0071 0.0071 0.0071 0.0071 0.0071 Columns 715 through 731 0.0071 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0073 0.0073 Columns 732 through 748 0.0073 0.0073 0.0073 0.0073 0.0073 0.0073 0.0073 0.0073 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 0.0074 Columns 749 through 765 0.0074 0.0074 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0075 0.0076 0.0076 0.0076 0.0076 0.0076 Columns 766 through 782 0.0076 0.0076 0.0077 0.0077 0.0077 0.0077 0.0077 0.0077 0.0077 0.0077 0.0077 0.0078 0.0078 0.0078 0.0078 0.0078 0.0078 Columns 783 through 799 0.0078 0.0078 0.0078 0.0078 0.0079 0.0079 0.0079 0.0079 0.0079 0.0079 0.0079 0.0079 0.0079 0.0079 0.0079 0.0080 0.0080 Columns 800 through 816 0.0080 0.0080 0.0080 0.0080 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0082 0.0082 0.0082 Columns 817 through 833 0.0082 0.0082 0.0082 0.0082 0.0082 0.0082 0.0082 0.0082 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0083 0.0084 0.0084 Columns 834 through 850 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0084 0.0085 0.0085 0.0085 0.0085 0.0085 Columns 851 through 867 0.0085 0.0085 0.0085 0.0085 0.0086 0.0086 0.0086 0.0086 0.0086 0.0086 0.0086 0.0086 0.0086 ...

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

p = 1 3 3 4 5 7 8 p1 = 0 2 1 -1 3 0 -5 y = 0