Problem 60760. Find the closest canyon prime

My wife and I celebrated our honeymoon and most recent anniversary in Yellowstone and Grand Teton National Parks. After returning from our latest trip, I made her a word puzzle involving geysers, mud pots, and canyons. Because canyons form when rock erodes and walls remain, a canyon in the puzzle was a word that could erode two or more letters from the interior to form a new word, leaving at least one of the original letters on each side. For example, if TOPLAS is eroded from PROTOPLASM, then PROM is formed.
This problem deals with canyon primes, defined as a prime number that can erode two or more of its digits, leaving at least one original digit on each side, and become a new prime. 4813 and 4817 are both canyon primes because eroding 81 from both leaves 43 and 47, which are prime. 29411 is a canyon prime because eroding 94 leaves 211, which is prime. 299623 is a canyon prime because eroding 996 leaves 223, which is prime.
Write a function that produces the canyon prime closest to the input number. If two numbers are equally distant from the input, choose the smaller.

Solution Stats

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Nov 21, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author279

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!