Question: Provide python code for below question. Ravindra Jadeja is a naughty CSE student in Siversity. Jadeja one day he tried to peek into his roommate

Provide python code for below question.

Provide python code for below question. Ravindra Jadeja is a naughty CSE

Ravindra Jadeja is a naughty CSE student in Siversity. Jadeja one day he tried to peek into his roommate Rohit Sharma's suitcase. The suitcase has a security system with 4-digit numbers. When Jadeja was trying to open the suitcase, Rohit caught him. Jadeja then smiles like an innocent boy. Now Rohit says that Jadeja will allow him to have a look inside the suitcase if he can do the unlocking in the following way. Rohit will reveal the actual pin Y and set the lock with 4 digit number X. Now Jadeja has to change only one digit of X at a time. The number he sets from X should be a prime number. Then one digit of that prime number can be changed where the next number should also be a prime number. In this way Jadeja has to change X into Y by changing one digit at a time where each number in the series should be a prime number. Since Jadeja is a lazy boy he was wondering what is the minimum number of times Z can do the iteration to convert X to Y. If suppose X = 1033 and Y = 8179, then the sequence is 1033, 1733, 3733, 3739, 3779, 8779, 8179. SO the answer Z = 6. Similarly if X = 1373 and Y = 8017 then Z=7. If X=1033 and Y = 1033 then Z=0. Sample Test Cases: Input: 1033 8179 Output: 6 Input: 1373 8017 Output: 7 Input: 1033 1033 Output: 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!