Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 322880

Submitted on 24 Sep 2013 by James

Correct

139Size
Leading solution size is 47.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
s=[5 7 6 3 2 5];
MinSum=Find_MinSum(s);
exp=13;
assert(exp==MinSum)
temp =
    29    29    29    29    29
    29     5     0     0    29
    29     7     6     0    29
    29     3     2     5    29
    29    29    29    29    29
ans =
    13
2
Pass
 
%%
s=[7 9 8 3 2 6 7 1 5   5 9   4   8   2   4 6   3   2   9   7   5 7   2   4   8   5   1   9 4   2   9   3   8   5   2   8  8   2   4   8   5   9   2   7   3];
MinSum=Find_MinSum(s);
exp=30;
assert(exp==MinSum)
temp =
   238   238   238   238   238   238   238   238   238   238   238
   238     7     0     0     0     0     0     0     0     0   238
   238     9     8     0     0     0     0     0     0     0   238
   238     3     2     6     0     0     0     0     0     0   238
   238     7     1     5     5     0     0     0     0     0   238
   238     9     4     8     2     4     0     0     0     0   238
   238     6     3     2     9     7     5     0     0     0   238
   238     7     2     4     8     5     1     9     0     0   238
   238     4     2     9     3     8     5     2     8     0   238
   238     8     2     4     8     5     9     2     7     3   238
   238   238   238   238   238   238   238   238   238   238   238
ans =
    30
3
Pass
 
%%
s=[21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];
MinSum=Find_MinSum(s);
exp=76;
assert(exp==MinSum)
temp =
   232   232   232   232   232   232   232   232
   232    21     0     0     0     0     0   232
   232    20    19     0     0     0     0   232
   232    18    17    16     0     0     0   232
   232    15    14    13    12     0     0   232
   232    11    10     9     8     7     0   232
   232     6     5     4     3     2     1   232
   232   232   232   232   232   232   232   232
ans =
    76
4
Pass
 
%%
s=1:28;
MinSum=Find_MinSum(s);
exp=63;
assert(exp==MinSum)
temp =
   407   407   407   407   407   407   407   407   407
   407     1     0     0     0     0     0     0   407
   407     2     3     0     0     0     0     0   407
   407     4     5     6     0     0     0     0   407
   407     7     8     9    10     0     0     0   407
   407    11    12    13    14    15     0     0   407
   407    16    17    18    19    20    21     0   407
   407    22    23    24    25    26    27    28   407
   407   407   407   407   407   407   407   407   407
ans =
    63
5
Pass
 
%%
s=[82 91 13 92 64 10 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 71 4 28 5 10 83 ];
MinSum=Find_MinSum(s);
exp=213;
assert(exp==MinSum)
temp =
  Columns 1 through 8
        2088        2088        2088        2088        2088        2088        2088        2088
        2088          82           0           0           0           0           0           0
        2088          91          13           0           0           0           0           0
        2088          92          64          10           0           0           0           0
        2088          28          55          96          97           0           0           0
        2088          16          98          96          49          81           0           0
        2088          15          43          92          80          96          66           0
        2088           4          85          94          68          76          75          40
        2088          66          18          71           4          28           5          10
        2088        2088        2088        2088        2088        2088        2088        2088
  Columns 9 through 10
        2088        2088
           0        2088
           0        2088
           0        2088
           0        2088
           0        2088
           0        2088
           0        2088
          83        2088
        2088        2088
ans =
   213
6
Pass
 
%%
s=[348 159 476 18 220 191 383 398 94 245 223 324 355 378 139 340 328 82 60 250 480 171 293 112 376 128 253 350 446 480 274 70 75 129 421 128 ];
MinSum=Find_MinSum(s);
exp=1409;
assert(exp==MinSum)
temp =
  Columns 1 through 8
        9198        9198        9198        9198        9198        9198        9198        9198
        9198         348           0           0           0           0           0           0
        9198         159         476           0           0           0           0           0
        9198          18         220         191           0           0           0           0
        9198         383         398          94         245           0           0           0
        9198         223         324         355         378         139           0           0
        9198         340         328          82          60         250         480           0
        9198         171         293         112         376         128         253         350
        9198         446         480         274          70          75         129         421
        9198        9198        9198        9198        9198        9198        9198        9198
  Columns 9 through 10
        9198        9198
           0        9198
           0        9198
           0        9198
           0        9198
           0        9198
           0        9198
           0        9198
         128        9198
        9198        9198
ans =
        1409