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 290760

Submitted on 27 Jul 2013 by Alfonso Nieto-Castanon

Correct

88Size
Leading solution size is 75.
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
 
%%
p1 = 13;
p2 = 29;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))

                    
2
Pass
 
%%
p1 = 389;
p2 = 269;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))

                    
3
Pass
 
%%
p1 = 761;
p2 = 397;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))

                    
4
Pass
 
%%
p1 = 983;
p2 = 239;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))

                    
5
Pass
 
%%
p1 = 271;
p2 = 439;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))

                    
6
Pass
 
%%
p1 = 877;
p2 = 733;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))

                    
7
Pass
 
%%
p1 = 2267;
p2 = 1153;
ladder = prime_ladder(p1,p2);
assert(all(isprime(ladder)))
assert(iscolumn(ladder))
assert(ladder(1)==p1)
assert(ladder(end)==p2)
assert(all(sum(diff(num2str(ladder))~=0,2)==1))