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 323422

Submitted on 25 Sep 2013 by James

Correct

9Size
Leading solution size is 4.
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
 
%%
feval(@assignin,'caller','score',0);

                    
2
Pass
 
%%
vec1 = [1 6 13];
vec2 = [1 2 4];
vec3 = [3 5 8];
vec4 = [5 9 11];
answer1 = 45;
answer2 = 2;
answer3 = 133;
answer4 = 222;
for i=1:5 % Warmup Calls to get valid timing
 value = get3HCRank(vec1);
end
ta=clock;
for i = 1:10000
 ansU1=get3HCRank(vec1);
 ansU2=get3HCRank(vec2);
 ansU3=get3HCRank(vec3);
 ansU4=get3HCRank(vec4);
end
t1=etime(clock,ta);
timing = t1 * 95;
benchmark = 100;
assert(isequal(ansU1,answer1))
assert(isequal(ansU2,answer2))
assert(isequal(ansU3,answer3))
assert(isequal(ansU4,answer4))
assert(timing < benchmark)
out = timing
feval(@assignin,'caller','score',out);
out =
   94.9510