Given 2 4-digit prime numbers. Find a path of prime numbers where only one digit is changed from the first given prime n

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Given 2 4-digit prime numbers. Find a path of prime numbers where only one digit is changed from the first given prime n

Post by answerhappygod »

Given 2 4-digit prime numbers. Find a path of prime numbers
where only one digit is changed from the first given prime
number to the 2nd given prime number. Write a program in
C++ to find how many change is needed to go through in the
process. The first digit must be nonzero. Here is a solution
of an example from 1033 to 8179, the cost is 6.
Input
One line with a positive number: the number of test cases (at
most 100). Then for each test case, one line with two numbers
separated by a blank. Both numbers are four-digit primes (without
leading zeros).
Output
One line for each case, either with a number stating the minimal
cost or containing the word "Impossible".
Given 2 4 Digit Prime Numbers Find A Path Of Prime Numbers Where Only One Digit Is Changed From The First Given Prime N 1
Given 2 4 Digit Prime Numbers Find A Path Of Prime Numbers Where Only One Digit Is Changed From The First Given Prime N 1 (13.4 KiB) Viewed 24 times
Sample Input Sample Output 3 6 1033 8179 7 1373 8017 0 1033 1033
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply