Cody

# Problem 44353. Group-wise Euclidean distance

Solution 1754688

Submitted on 19 Mar 2019 by Hans Kramer
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
assessFunctionAbsence({'regexp','regexpi','regexprep','str2num','tic','toc','persistent','global','rng','assert','!','system','unix','noCheater'},'FileName','groupDist.m')

2   Pass
fid = fopen('noCheater.p','Wb'); fwrite(fid, hex2dec(reshape([ '7630312E30307630302E30300007701CAB777FB100000015000000740000007E3D5C20F'...' '5319EEB8B0D3D9C9C87C18B91C13D7310D9D8E837C95E62D49A3FE08B071790DBC222B5'... '839E9A19EA6AA7CF3785A7E7CEC1CFE46E0E9A5DB7C82D69A4FAB7BF308D0871C342A5F'... 'EF9AF61623F1D97F80207388D54ABA3CB3D551617DA33AA3F5040CD425FC9B29E2A4233'... 'AE7C5ADEF399'],2,[]).')); rehash path; fclose(fid); assert(noCheater(),'Cheater detected!')

3   Pass
g = [2 1 3 2 1].'; x = [3 10 15 8 5].'; y_correct = [0 2 5 2 0 7 5 7 0]; assert(isequaln(y_correct,groupDist(x,g)))

array = 0×0 empty cell array array = 1×1 cell array {2×1 double} array = 1×2 cell array {2×1 double} {2×1 double} array = 1×3 cell array {2×1 double} {2×1 double} {[15]}

4   Pass
g = [1 2 2].'; x = [0 0 5 12 3 4]; y_correct = [0 5; 5 0]; assert(isequal(y_correct,groupDist(x,g)))

array = 0×0 empty cell array array = 1×1 cell array {1×2 double} array = 1×2 cell array {1×2 double} {2×2 double}

5   Pass
g = [2 2 3 3 3 1].'; x = [-5 12 3 4 -7 -24 25 4 9 40 0 0]; y_correct = [0 5 25; 5 0 22 25 22 0]; assert(isequal(y_correct,groupDist(x,g)))

array = 0×0 empty cell array array = 1×1 cell array {1×2 double} array = 1×2 cell array {1×2 double} {2×2 double} array = 1×3 cell array {1×2 double} {2×2 double} {3×2 double}

6   Pass
g = randperm(10).'; x = rand(10,1); a = sortrows([g,x]); y_correct = abs(a(:,2)-a(:,2).'); assert(isequal(round(y_correct,10),round(groupDist(x,g),10)))

array = 0×0 empty cell array array = 1×1 cell array {[0.3492]} array = 1×2 cell array {[0.3492]} {[0.7640]} array = 1×3 cell array {[0.3492]} {[0.7640]} {[0.6320]} array = 1×4 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} array = 1×5 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} {[0.8618]} array = 1×6 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} {[0.8618]} {[0.5256]} array = 1×7 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} {[0.8618]} {[0.5256]} {[0.2135]} array = 1×8 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} {[0.8618]} {[0.5256]} {[0.2135]} {[0.3198]} array = 1×9 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} {[0.8618]} {[0.5256]} {[0.2135]} {[0.3198]} {[0.3497]} array = 1×10 cell array {[0.3492]} {[0.7640]} {[0.6320]} {[0.5491]} {[0.8618]} {[0.5256]} {[0.2135]} {[0.3198]} {[0.3497]} {[0.4999]}

7   Pass
g = [1,2,3].'; x = [2,5,10].'; y_correct = [0 3 8 3 0 5 8 5 0]; assert(isequaln(y_correct,groupDist(x,g)))

array = 0×0 empty cell array array = 1×1 cell array {[2]} array = 1×2 cell array {[2]} {[5]} array = 1×3 cell array {[2]} {[5]} {[10]}

8   Pass
global t t = zeros(1,3); rng(923,'twister'); n = 5e3; d = 3; m = 5; x = rand(n,d); g = randi(m,n,1); y_correct = [0,0.00653919638188362,0.00319052186150122,0.00858841434457234,0.00359654235965771 0.00653919638188362,0,0.00855286615862212,0.00589790293838067,0.00484910151004134 0.00319052186150122,0.00855286615862212,0,0.00591041083080696,0.00483607360689871 0.00858841434457234,0.00589790293838067,0.00591041083080696,0,0.00695738487959094 0.00359654235965771,0.00484910151004134,0.00483607360689871,0.00695738487959094,0]; tic, y = groupDist(x,g); t(1) = toc; assert(isequal(round(y_correct,10),round(y,10)))

array = 0×0 empty cell array array = 1×1 cell array {983×3 double} array = 1×2 cell array {983×3 double} {1026×3 double} array = 1×3 cell array {983×3 double} {1026×3 double} {999×3 double} array = 1×4 cell array {983×3 double} {1026×3 double} {999×3 double} {965×3 double} array = 1×5 cell array {983×3 double} {1026×3 double} {999×3 double} {965×3 double} {1027×3 double}

9   Pass
global t rng(123) rng(max('cody5'),'combRecursive'); n = 5e3; d = 3; m = 100; x = 10*rand(n,d); g = randi(m,n,1); tic, y = groupDist(x,g); t(2) = toc; assert(norm(y-y.') < 1e-11 && all(~diag(y)) && all(size(y)==m) && abs(det(y)-0.030846735888559)<1e-8 &&... abs(cond(y)-1.606720826682107e+04) < 1e-6 && abs(max(nonzeros(y))-1.058563379304832)<1e-10 &&... abs(mean(nonzeros(y))-0.419901913602729)<1e-8)

array = 0×0 empty cell array array = 1×1 cell array {53×3 double} array = 1×2 cell array {53×3 double} {40×3 double} array = 1×3 cell array {53×3 double} {40×3 double} {56×3 double} array = 1×4 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} array = 1×5 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} array = 1×6 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} array = 1×7 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} array = 1×8 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} array = 1×9 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} array = 1×10 cell array {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} array = 1×11 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Column 11 {34×3 double} array = 1×12 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 12 {34×3 double} {60×3 double} array = 1×13 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 13 {34×3 double} {60×3 double} {56×3 double} array = 1×14 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 14 {34×3 double} {60×3 double} {56×3 double} {49×3 double} array = 1×15 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 15 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} array = 1×16 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 16 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} array = 1×17 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 17 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} array = 1×18 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 18 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} array = 1×19 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 19 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} array = 1×20 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} array = 1×21 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Column 21 {39×3 double} array = 1×22 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 22 {39×3 double} {53×3 double} array = 1×23 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 23 {39×3 double} {53×3 double} {37×3 double} array = 1×24 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 24 {39×3 double} {53×3 double} {37×3 double} {53×3 double} array = 1×25 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 25 {39×3 double} {53×3 double} {37×3 double} {53×3 double} {47×3 double} array = 1×26 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 26 {39×3 double} {53×3 double} {37×3 double} {53×3 double} {47×3 double} {57×3 double} array = 1×27 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 27 {39×3 double} {53×3 double} {37×3 double} {53×3 double} {47×3 double} {57×3 double} {36×3 double} array = 1×28 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 28 {39×3 double} {53×3 double} {37×3 double} {53×3 double} {47×3 double} {57×3 double} {36×3 double} {44×3 double} array = 1×29 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 29 {39×3 double} {53×3 double} {37×3 double} {53×3 double} {47×3 double} {57×3 double} {36×3 double} {44×3 double} {37×3 double} array = 1×30 cell array Columns 1 through 10 {53×3 double} {40×3 double} {56×3 double} {46×3 double} {46×3 double} {51×3 double} {54×3 double} {42×3 double} {65×3 double} {54×3 double} Columns 11 through 20 {34×3 double} {60×3 double} {56×3 double} {49×3 double} {43×3 double} {47×3 double} {57×3 double} {48×3 double} {54×3 double} {44×3 double} Columns 21 through 30 {39×3 double} {53×3 double} {37×3 dou...

10   Pass
global t rng(sum('Cody5, Oct. 16, 2017'),'multFibonacci') n = 5e3; d = 1e2; m = 100; x = 5*randn(n,d) + 20; g = randi(m,n,1); tic, y = groupDist(x,g); t(3) = toc; assert(norm(y-y.') < 1e-11 && all(~diag(y)) && all(size(y)==m) && ... abs(cond(y)-2.024633860688276e+02) < 1e-8 && abs(max(nonzeros(y))-57.768463869822135)<1e-10 &&... abs(mean(nonzeros(y))-53.852605466762945)<1e-8)

array = 0×0 empty cell array array = 1×1 cell array {56×100 double} array = 1×2 cell array {56×100 double} {46×100 double} array = 1×3 cell array {56×100 double} {46×100 double} {53×100 double} array = 1×4 cell array {56×100 double} {46×100 double} {53×100 double} {39×100 double} array = 1×5 cell array {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} array = 1×6 cell array {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} array = 1×7 cell array {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} array = 1×8 cell array {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} array = 1×9 cell array {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} array = 1×10 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Column 10 {54×100 double} array = 1×11 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 11 {54×100 double} {56×100 double} array = 1×12 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 12 {54×100 double} {56×100 double} {36×100 double} array = 1×13 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 13 {54×100 double} {56×100 double} {36×100 double} {47×100 double} array = 1×14 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 14 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} array = 1×15 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 15 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} array = 1×16 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 16 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} array = 1×17 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 17 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} array = 1×18 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} array = 1×19 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Column 19 {53×100 double} array = 1×20 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 20 {53×100 double} {57×100 double} array = 1×21 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 21 {53×100 double} {57×100 double} {47×100 double} array = 1×22 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 22 {53×100 double} {57×100 double} {47×100 double} {65×100 double} array = 1×23 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 23 {53×100 double} {57×100 double} {47×100 double} {65×100 double} {39×100 double} array = 1×24 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 24 {53×100 double} {57×100 double} {47×100 double} {65×100 double} {39×100 double} {48×100 double} array = 1×25 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 25 {53×100 double} {57×100 double} {47×100 double} {65×100 double} {39×100 double} {48×100 double} {52×100 double} array = 1×26 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 26 {53×100 double} {57×100 double} {47×100 double} {65×100 double} {39×100 double} {48×100 double} {52×100 double} {57×100 double} array = 1×27 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 27 {53×100 double} {57×100 double} {47×100 double} {65×100 double} {39×100 double} {48×100 double} {52×100 double} {57×100 double} {55×100 double} array = 1×28 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 double} {48×100 double} {55×100 double} Columns 10 through 18 {54×100 double} {56×100 double} {36×100 double} {47×100 double} {57×100 double} {44×100 double} {43×100 double} {47×100 double} {56×100 double} Columns 19 through 27 {53×100 double} {57×100 double} {47×100 double} {65×100 double} {39×100 double} {48×100 double} {52×100 double} {57×100 double} {55×100 double} Column 28 {46×100 double} array = 1×29 cell array Columns 1 through 9 {56×100 double} {46×100 double} {53×100 double} {39×100 double} {56×100 double} {41×100 double} {47×100 doubl...

11   Pass
global t fid = fopen('score.p','Wb'); fwrite(fid,uint8(sscanf([... '7630312E30307630302E3030000B901C454EFFB100000031000001330000018D483A60'... '366BC9545F84AE26323B67424D4E8A7A2E5B7D8ACAA45A1C3C5C8B33E245C95243E3CB'... 'AF5D0D993BDA70B7AB5DA365A83E8CA87FFC45265E23EF80943784C5F48E6E53D5DA34'... 'F1F2ECD34683EABE3B7461DC9E8004CC50B2A79D73495F6F625B5365602B2E6C6093D2'... '997D371DA457CE82327E686AF512A507B2CB62A375BFD1B283DDD2C01EDEF2771EDAA3'... '6ABB4852BA4061E20149688E812EB41A9AF8627EF35755492D2830EB8718BCFE88027E'... '6EA960B63A3B3E26E0451B1DCF14F3C20E70D9D93B08E7FF4AE8D82E7CC38042FD38F7'... 'A14D312EF5652823FEB7E8B52AF5C69F5E7D16B116B5F979EDA77459D6BB61B7971A51'... '041227DD601319D667DF62E8DA5E381FDD07A2806FE835BD2569E5315CDFC19C6B6A2B'... '4F0FF6BA803F1759ACAB133CCFAB6D5A5D002FC2C5F381F0'],'%2X'))); fclose(fid); score(round(5*sum(t))) fprintf('The execution time of test case %d is %.5f seconds \n',[5:7;t]) fprintf('The total execution time is %.5f seconds \n',sum(t)) assert(sum(t)<20, 'Sorry, your solution is too slow. The execution time must not exceed 20 seconds.')

The execution time of test case 5 is 0.30576 seconds The execution time of test case 6 is 3.28767 seconds The execution time of test case 7 is 7.24369 seconds The total execution time is 10.83712 seconds