Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions