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 consecutive interior 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
Problem Comments
-
2 Comments
William
on 12 Nov 2024 at 14:34
Chris - This is a clever problem! Is it a condition that the eroded inner digits of a canyon prime be *consecutive*? In Test #6, my solution is identifying 99833 as a closer canyon prime than 99828, on the basis that 99833 is prime and 983 is prime. In that case, there are two canyons!
ChrisR
2 hours and 34 minutes ago
Good question. I clarified my completely arbitrary definition of canyon primes to include that the digits must be consecutive. But if you know of good hikes to river cross-sections with multiple canyons, please tell me!
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
-
4 Solvers
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!