In the SPOJ PPATH problem, we are given two four-digit primes, and we need to convert as little as possible, the first stroke to the second, changing one digit at a time, and at each step the number should be prime. We should output “IMPOSSIBLE” if primes cannot be converted in this way.
However, solutions to the problem in which the impossible case was not even considered were adopted, which leads to the assumption that each four-digit prime can be converted to any other four-digit number in the indicated order. I could not prove it. It's true? How can we prove this formally? Also, is there a general result for n-bit primes?
source share