Cody

# Problem 1893. GJam 2014 China Rd A: Library Sorting (Small)

Solution 323695

Submitted on 26 Sep 2013 by Alfonso Nieto-Castanon
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
%% tic v=[1 ]; vexp=[1 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

2   Pass
%% v=[2 1 ]; vexp=[2 1 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

3   Pass
%% v=[1 2 3 ]; vexp=[1 2 3 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

4   Pass
%% v=[1 2 3 4 5 ]; vexp=[1 4 3 2 5 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

5   Pass
%% v=[5 2 3 4 1 ]; vexp=[1 4 3 2 5 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

6   Pass
%% v=[-87 -87 -85 -83 -71 -71 98 96 -67 -63 -59 -53 -47 -41 96 -41 82 -37 -29 82 -25 -25 80 -21 -13 -11 5 76 72 72 66 66 66 9 60 15 31 35 56 52 52 46 42 39 45 42 40 36 45 30 24 18 51 18 12 53 0 63 -6 65 -10 -12 67 69 79 85 85 -14 89 -16 -22 89 -24 91 -24 -26 -30 -38 -38 -38 -42 -44 -58 -58 -60 -62 -66 -68 -70 -70 -82 -82 -86 -86 -86 -94 -100 ]; vexp=[-87 -87 -85 -83 -71 -71 98 96 -67 -63 -59 -53 -47 -41 96 -41 82 -37 -29 82 -25 -25 80 -21 -13 -11 5 76 72 72 66 66 66 9 60 15 31 35 56 52 52 46 42 39 45 42 40 36 45 30 24 18 51 18 12 53 0 63 -6 65 -10 -12 67 69 79 85 85 -14 89 -16 -22 89 -24 91 -24 -26 -30 -38 -38 -38 -42 -44 -58 -58 -60 -62 -66 -68 -70 -70 -82 -82 -86 -86 -86 -94 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

7   Pass
%% v=[-95 98 -81 -55 90 -29 -19 35 37 75 79 85 93 97 56 54 14 14 0 -14 -22 -34 -38 -46 -62 -90 -98 ]; vexp=[-95 98 -81 -55 90 -29 -19 35 37 75 79 85 93 97 56 54 14 14 0 -14 -22 -34 -38 -46 -62 -90 -98 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

8   Pass
%% v=[-89 -75 -73 -65 86 86 68 66 -41 -37 -25 56 5 21 25 52 36 26 14 27 29 35 45 6 51 63 87 93 -22 95 -26 -48 -54 -70 95 -86 -92 -96 ]; vexp=[-89 -75 -73 -65 86 86 68 66 -41 -37 -25 56 5 21 25 52 36 26 14 27 29 35 45 6 51 63 87 93 -22 95 -26 -48 -54 -70 95 -86 -92 -96 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

9   Pass
%% v=[76 -7 ]; vexp=[76 -7 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

10   Pass
%% v=[-93 96 -91 86 -87 -87 -67 -53 68 30 -33 0 -33 -13 1 0 3 -10 3 -10 -16 19 23 45 51 -18 53 -30 -36 -72 79 -82 -96 83 91 ]; vexp=[-93 96 -91 86 -87 -87 -67 -53 68 30 -33 0 -33 -13 1 0 3 -10 3 -10 -16 19 23 45 51 -18 53 -30 -36 -72 79 -82 -96 83 91 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

11   Pass
%% v=[-87 100 96 -81 86 -79 -79 -77 -73 -69 -69 -65 82 -59 -59 70 70 -57 -49 -47 70 -43 -41 54 -35 -31 -31 -29 -25 -17 -13 -5 50 -5 -3 7 21 25 46 27 27 44 31 33 35 37 44 49 42 38 49 51 34 69 34 75 83 20 85 87 91 91 14 12 10 6 0 0 0 -8 -8 -20 -24 -26 -34 -36 -40 -52 -56 -60 -66 -68 -68 -72 -72 -80 -84 -84 -90 -90 ]; vexp=[-87 100 96 -81 86 -79 -79 -77 -73 -69 -69 -65 82 -59 -59 70 70 -57 -49 -47 70 -43 -41 54 -35 -31 -31 -29 -25 -17 -13 -5 50 -5 -3 7 21 25 46 27 27 44 31 33 35 37 44 49 42 38 49 51 34 69 34 75 83 20 85 87 91 91 14 12 10 6 0 0 0 -8 -8 -20 -24 -26 -34 -36 -40 -52 -56 -60 -66 -68 -68 -72 -72 -80 -84 -84 -90 -90 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

12   Pass
%% v=[-87 100 -81 -75 96 86 -71 -71 86 -33 -27 -25 82 -21 76 -11 68 5 7 9 13 68 15 25 41 41 51 61 56 61 56 67 54 67 48 83 89 91 99 34 30 28 16 16 10 10 4 0 0 0 0 -24 -26 -26 -34 -48 -50 -62 -66 -92 -100 ]; vexp=[-87 100 -81 -75 96 86 -71 -71 86 -33 -27 -25 82 -21 76 -11 68 5 7 9 13 68 15 25 41 41 51 61 56 61 56 67 54 67 48 83 89 91 99 34 30 28 16 16 10 10 4 0 0 0 0 -24 -26 -26 -34 -48 -50 -62 -66 -92 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

13   Pass
%% v=[-93 -89 -87 88 -85 -75 -65 -63 -61 -59 -49 84 -39 -37 80 80 -37 -25 -11 -7 78 -5 78 72 3 5 9 58 11 50 46 23 29 29 31 35 44 37 49 67 71 44 40 30 71 30 28 24 75 75 79 83 18 97 99 6 6 2 0 -4 -8 -10 -16 -18 -30 -32 -34 -36 -38 -46 -46 -48 -48 -52 -54 -56 -66 -68 -88 -90 -100 -100 -100 ]; vexp=[-93 -89 -87 88 -85 -75 -65 -63 -61 -59 -49 84 -39 -37 80 80 -37 -25 -11 -7 78 -5 78 72 3 5 9 58 11 50 46 23 29 29 31 35 44 37 49 67 71 44 40 30 71 30 28 24 75 75 79 83 18 97 99 6 6 2 0 -4 -8 -10 -16 -18 -30 -32 -34 -36 -38 -46 -46 -48 -48 -52 -54 -56 -66 -68 -88 -90 -100 -100 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

14   Pass
%% v=[90 -89 90 74 -87 62 -83 -79 58 -77 -75 -75 -63 52 52 -59 46 42 -49 -39 -31 36 12 -25 6 -13 -11 5 9 17 23 29 39 -2 -8 -10 47 63 -28 -54 -70 -74 -78 63 65 83 -82 -84 91 97 97 ]; vexp=[90 -89 90 74 -87 62 -83 -79 58 -77 -75 -75 -63 52 52 -59 46 42 -49 -39 -31 36 12 -25 6 -13 -11 5 9 17 23 29 39 -2 -8 -10 47 63 -28 -54 -70 -74 -78 63 65 83 -82 -84 91 97 97 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

15   Pass
%% v=[-97 88 -93 74 70 46 38 36 -91 -85 -83 -77 -67 -63 -55 34 -45 32 -37 16 0 0 -23 -21 -2 -4 5 13 27 -10 -32 -38 -38 -50 39 -56 45 49 -56 77 -56 87 95 97 -62 -62 -68 -68 -72 -80 -94 ]; vexp=[-97 88 -93 74 70 46 38 36 -91 -85 -83 -77 -67 -63 -55 34 -45 32 -37 16 0 0 -23 -21 -2 -4 5 13 27 -10 -32 -38 -38 -50 39 -56 45 49 -56 77 -56 87 95 97 -62 -62 -68 -68 -72 -80 -94 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

16   Pass
%% v=[81 29 29 -71 -70 16 -70 -93 25 97 51 3 -8 39 -83 97 98 -86 -53 69 58 86 19 75 9 87 -84 66 75 82 85 -87 53 7 65 99 -93 59 -74 4 1 -15 -22 59 -35 -15 51 -10 -27 -98 60 -17 37 29 -98 69 83 9 51 13 -12 -13 50 -39 45 5 -34 75 -84 15 -91 18 -97 -8 0 -44 34 79 -13 -74 -92 80 -84 -92 -32 -46 -26 46 -16 -32 -72 16 84 -46 22 -32 84 58 28 -60 ]; vexp=[-97 -93 -93 -91 98 86 84 -87 -83 -71 -53 -39 84 -35 -27 -17 82 80 -15 -15 66 60 -13 -13 1 3 58 58 5 50 7 9 9 13 15 19 25 29 46 34 29 29 28 37 39 45 51 22 51 18 16 51 53 59 16 59 65 69 69 75 4 75 0 75 79 81 -8 83 -8 85 87 -10 97 -12 -16 -22 -26 97 99 -32 -32 -32 -34 -44 -46 -46 -60 -70 -70 -72 -74 -74 -84 -84 -84 -86 -92 -92 -98 -98 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

17   Pass
%% v=[10 50 52 3 -29 51 29 -89 55 -34 -77 -41 65 7 -89 0 -44 -98 61 -21 11 -57 -10 95 -12 -25 91 28 90 -49 -57 97 57 -47 33 -59 7 -39 55 91 -89 -41 -7 -18 -61 -93 78 -57 97 45 44 -59 5 38 9 28 -38 11 -36 -92 15 -70 44 -84 18 -24 38 20 -54 0 2 44 28 12 42 -22 74 6 -72 -52 34 -50 30 -44 -6 -42 98 -96 42 38 64 92 -36 92 -90 2 -6 -44 -98 -2 ]; vexp=[98 92 92 -93 -89 -89 -89 -77 -61 90 -59 -59 -57 -57 -57 78 74 64 -49 -47 -41 -41 52 -39 50 -29 -25 44 44 -21 -7 3 5 7 7 9 11 11 15 29 33 45 51 44 55 55 42 57 61 65 42 91 91 38 95 38 38 97 34 30 97 28 28 28 20 18 12 10 6 2 2 0 0 -2 -6 -6 -10 -12 -18 -22 -24 -34 -36 -36 -38 -42 -44 -44 -44 -50 -52 -54 -70 -72 -84 -90 -92 -96 -98 -98 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

18   Pass
%% v=[34 46 -93 78 -26 11 77 26 47 73 75 53 -89 -52 71 19 -52 -47 16 -19 74 49 21 1 -33 -89 5 -74 67 -55 88 -85 1 -41 93 53 -97 61 -71 -85 77 -45 -1 0 74 95 67 -65 -27 -2 -44 -8 -37 27 36 -58 71 -8 -95 43 17 -19 25 -5 -10 42 10 -64 27 94 41 -69 37 81 -97 -50 -54 66 -22 40 -62 90 -70 40 48 48 52 48 20 98 -42 92 88 40 36 -28 -10 -44 -52 96 ]; vexp=[98 96 -97 94 92 -97 -95 90 -93 -89 -89 -85 -85 88 -71 -69 88 -65 78 -55 74 -47 -45 -41 -37 -33 -27 74 -19 -19 66 -5 -1 1 1 5 11 17 19 21 25 27 27 52 48 37 41 43 47 48 48 46 49 53 42 40 53 40 61 67 67 71 71 73 40 36 36 34 75 26 77 77 81 93 95 20 16 10 0 -2 -8 -8 -10 -10 -22 -26 -28 -42 -44 -44 -50 -52 -52 -52 -54 -58 -62 -64 -70 -74 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

19   Pass
%% v=[-27 ]; vexp=[-27 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

20   Pass
%% v=[53 75 55 -92 23 -19 83 -70 95 43 -57 1 -11 -9 42 -98 -30 -35 -35 94 -95 -43 -11 -44 96 53 23 -80 -77 -32 -34 45 -16 -2 -77 56 -92 0 -15 38 36 4 -18 72 -84 88 48 58 82 -4 88 -62 -10 -30 10 -100 22 0 -12 -40 -48 -74 ]; vexp=[-95 -77 -77 96 -57 -43 -35 94 -35 -19 -15 -11 -11 -9 88 88 82 1 23 72 23 43 45 58 56 53 53 48 55 42 38 75 36 22 83 10 4 0 95 0 -2 -4 -10 -12 -16 -18 -30 -30 -32 -34 -40 -44 -48 -62 -70 -74 -80 -84 -92 -92 -98 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

21   Pass
%% v=[-87 63 -79 74 66 5 -51 -9 69 -58 -23 77 -75 -71 91 0 -40 41 -79 32 27 90 66 -56 100 -48 -80 14 -24 ]; vexp=[-87 -79 -79 100 90 -75 -71 -51 -23 74 -9 5 27 41 63 66 66 69 77 32 91 14 0 -24 -40 -48 -56 -58 -80 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

22   Pass
%% v=[91 34 34 -92 -34 42 99 51 0 54 17 -51 -31 -45 35 -33 92 7 -33 -45 0 -15 76 58 58 100 85 -68 5 -20 -13 83 -39 89 55 89 -90 84 -40 20 90 54 -84 -90 38 -100 60 64 54 32 -30 86 -60 90 -46 -58 -50 ]; vexp=[-51 100 92 90 90 86 -45 -45 84 76 -39 -33 -33 -31 -15 -13 64 5 7 17 60 35 58 58 54 54 51 54 55 42 83 85 89 89 91 99 38 34 34 32 20 0 0 -20 -30 -34 -40 -46 -50 -58 -60 -68 -84 -90 -90 -92 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

23   Pass
%% v=[-41 25 30 -41 20 51 -75 -72 45 -73 75 -77 60 -79 -45 80 19 49 -25 -99 -16 71 55 -79 -35 31 -66 61 -19 -45 -55 -34 73 -55 17 -29 -41 65 -93 51 -58 62 99 73 59 -66 83 -95 -23 62 -82 -81 -31 -33 -9 -41 1 83 36 92 82 80 0 10 78 38 70 0 -52 4 -56 88 -92 -14 56 -6 -74 -90 92 96 86 96 -88 ]; vexp=[-99 -95 96 -93 96 -81 -79 92 -79 -77 -75 -73 92 -55 -55 88 -45 -45 -41 -41 86 -41 -41 -35 -33 -31 82 -29 -25 -23 -19 80 -9 1 17 19 25 31 45 49 80 78 51 51 55 70 59 61 65 62 62 71 73 73 75 83 83 99 60 56 38 36 30 20 10 4 0 0 -6 -14 -16 -34 -52 -56 -58 -66 -66 -72 -74 -82 -88 -90 -92 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

24   Pass
%% v=[-55 93 -57 -68 25 48 -100 75 11 -82 -60 64 74 19 11 -87 -56 -10 45 74 -21 -5 1 12 55 66 -72 73 37 85 -97 -80 51 44 55 -54 -15 -79 32 -93 1 23 -77 -86 90 -71 82 4 14 -100 55 -51 33 -60 65 -30 -34 -37 -75 75 90 33 -35 38 -97 -72 49 4 24 42 88 -60 -78 -68 0 48 -44 -56 24 -12 -48 -78 100 68 -32 -58 24 -44 94 ]; vexp=[-97 -97 -93 100 -87 94 90 -79 -77 90 88 82 74 -75 -71 -57 74 68 -55 66 -51 -37 -35 64 -21 48 48 -15 -5 1 1 44 11 42 11 38 19 23 32 25 33 33 37 24 24 45 24 14 12 4 49 51 55 4 55 0 -10 55 65 73 -12 75 75 -30 85 -32 93 -34 -44 -44 -48 -54 -56 -56 -58 -60 -60 -60 -68 -68 -72 -72 -78 -78 -80 -82 -86 -100 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

25   Pass
%% v=[-41 97 83 0 -33 87 29 18 21 30 90 4 -10 -56 -66 79 -25 55 -40 -55 1 1 0 85 -66 -15 36 -68 -100 65 -8 -77 64 -47 -60 -96 83 -67 12 -85 11 24 -63 -50 17 -60 ]; vexp=[-85 -77 -67 90 -63 -55 -47 64 -41 36 30 24 18 12 4 -33 -25 -15 0 1 1 11 0 17 -8 21 -10 -40 -50 29 -56 55 -60 65 -60 -66 79 83 -66 83 85 -68 87 -96 97 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

26   Pass
%% v=[-75 77 13 57 62 43 -9 13 -61 -37 -19 49 -1 65 -53 -87 -40 -73 -33 80 -11 15 73 -42 -58 -20 85 -97 -57 22 -46 -60 8 62 30 -84 66 40 58 -44 -100 ]; vexp=[-97 -87 -75 -73 80 -61 -57 -53 -37 -33 -19 -11 -9 -1 13 13 66 15 43 62 49 57 65 62 58 40 73 77 85 30 22 8 -20 -40 -42 -44 -46 -58 -60 -84 -100 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

27   Pass
%% v=[80 30 85 -54 -87 -32 47 33 57 -57 -64 50 67 -84 58 -79 37 -39 77 65 55 26 -58 47 -24 50 -34 72 65 30 38 -57 -49 13 -81 -3 -90 73 -69 91 -38 -49 -52 87 81 -70 51 -98 82 80 0 96 -68 -34 -54 -96 ]; vexp=[96 82 -87 80 -81 80 -79 -69 -57 -57 72 58 -49 50 50 -49 -39 -3 13 33 37 38 30 47 30 26 0 -24 47 -32 -34 51 55 57 65 65 -34 67 73 77 -38 81 -52 85 87 -54 91 -54 -58 -64 -68 -70 -84 -90 -96 -98 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

28   Pass
%% v=[45 7 -49 57 7 -11 -7 53 -83 99 -90 9 87 100 16 -58 45 33 -98 30 -58 -50 -29 15 -66 76 -86 58 4 -82 ]; vexp=[-83 -49 -29 -11 -7 7 7 9 15 33 100 45 45 76 58 30 53 57 16 4 -50 -58 87 99 -58 -66 -82 -86 -90 -98 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

29   Pass
%% v=[-13 20 -29 34 47 -38 -55 -25 37 41 -87 47 31 -63 -27 -68 -35 32 77 11 -7 -91 -67 -32 59 41 -11 -81 10 96 -50 -11 74 0 -42 -22 92 -72 46 0 0 -80 78 -32 58 4 24 -22 -56 -34 60 ]; vexp=[-91 96 -87 92 -81 78 -67 -63 -55 -35 -29 -27 -25 -13 -11 74 -11 60 -7 11 31 37 41 58 41 47 47 59 46 34 32 77 24 20 10 4 0 0 0 -22 -22 -32 -32 -34 -38 -42 -50 -56 -68 -72 -80 ]; vout=Sort_CH(v); assert(isequal(vout,vexp))

30   Pass
%% v=[35 69 33 35 -7 -54 -89 95 -95 -72 2 42 -89 -10 17 -65 -99 -43 27 95 71 61 -5 -95 -82 21 47 79 -59 52 -44 -10 -19 53 35 -92 -35 -61 -95 -43 35 -98 95 -2 -19 66 89 -54 32 -18 36 72 -64 -10 -88 -50 -8 38 88 -50 ]; vexp=[-99 -95 -95 -95 -89 88 -89 -65 -61 72 66 52 -59 42 -43 -43 -35 -19 -19 -7 -5 17 21 27 38 33 35 35 35 36 32 2 35 47 53 -2 61 69 71 79 89 -8 95 -10 95 -10 95 -10 -18 -44 -50 -50 -54 -54 -64 -72 -82 -88 -92 -98 ]; vout=Sort_CH(v); assert(isequal(vout,vexp)) toc

Elapsed time is 0.030637 seconds.