Problem 1394. Prime Ladders
A word ladder transforms one word to another by means of single-letter mutations. So COLD can become WARM like so (there are often multiple solutions):
COLD CORD CARD WARD WARM
A number ladder does much the same thing, changing one digit at a time. A prime ladder is a number ladder with the additional constraint that each element is a prime number. Here is a prime ladder that connects 757 and 139
757 157 137 139
Given two numbers p1 and p2, construct a prime ladder column vector in which p1 is the first element, p2 is the last element, and each successive row differs by exactly one digit from the preceding element.
To restate the above example, consider
p1 = 757 p2 = 139
for which an acceptable answer is
ladder = [757; 157; 137; 139]
You can assume that p1 and p2 contain the same number of digits. I am not looking for a unique answer. I will only check that the conditions of a prime ladder are met.
Solution Stats
Problem Comments
-
3 Comments
Couldn't did it without binbin's help... anyway, absolutely nice problem! worth look into it.
Glad you liked it!
"I will only check that the conditions of a prime ladder are met."
Nicely done
Solution Comments
Show commentsProblem Recent Solvers47
Suggested Problems
-
Back to basics 8 - Matrix Diagonals
924 Solvers
-
408 Solvers
-
Implement a bubble sort technique and output the number of swaps required
296 Solvers
-
306 Solvers
-
483 Solvers
More from this Author50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!