Question: Please solve this question using Java . Do not copy online solutions, explain your code, and explain how did you solve it, how would you

Please solve this question using Java. Do not copy online solutions, explain your code, and explain how did you solve it, how would you do better given more time.

Scrolling Numbers

Programming challenge description:

You have been given a special kind of lock to open called a "Scrolling Combination Lock" The lock has 9 keys numbered from 1 to 9. Additionally, there are two numbers printed below the keys suggesting a range of values. To open the lock, you must enter all the numbers in the range that are "Scatting Numbers"

A Scrolling Number is a number that has two characteristics:

  1. No digits repeat themselves.
  2. All digits in the number "scroll" through themselves.

How To Scroll:

Beginning with the leftmost digit, take that digit's value D and move D digits to the right. When scrolling, if the last digit of the number is reached, wrap back to the leftmost digit as many times as needed to move to a total of D digits. After scrolling to a new digit, repeat the process using the new digits' value for D.

A Scrolling Number will visit every digit exactly once and end at the leftmost digit.

For example, consider Scrolling Number 6231.

  1. Start with the digit 6.
  2. Advance 6 steps, wrapping around once, to the digit 3.
  3. From 3 advance to 2, again wrapping around once
  4. From 2 advance to 1
  5. From 1 advance to 6 in a final wrap

Input: The input is the range of integers to consider for the lock, expressed in the format A, B Each integer A and B is 1 <= A <= B <= 10000.

Output: Print all Scrolling Numbers between A and B inclusive, each on a single line. These are the combinations that will open the lock.

If there are no Scrolling Numbers between A and B print -1.

Test 1

Test Input 100,500

Expected Output 147 174 258 285 417 471

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!