Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider this master lock shown on the right. The dial has 40 marks. Let's say the combination for this lock is: 38-16-22. Here is

Consider this master lock shown on the right. The dial has 40 marks. Let's say the combination for this lock is: 38-16-22. Here is how you can open the lock: Turn the dial clockwise 2 full turns. Then stop at the first number of the combination, (e.g., 38 in our case) Turn the dial counter-clockwise 1 full turn. Continue turning counter-clockwise until the 2nd number is reached (e.g., 16 in our case) Turnthe dial clockwise again until the 3rd number is reached. Pull the shackle and the lock will open. 30 Master Sample Input 6 0 30 0 30 5 355 35 0 20 0 20 7 27 7 27 0 10 0 10 9 19 9 19 10 15 Shackle Now if you know the initial position of the dial and the combination of the lock, you should be able to compute atleast how many degrees (lower bound) the dial needs to rotate in total (clockwise plus counter-clockwise) to open the lock. Sample Output 1350 1350 1620 1620 1890 1890 Indicator Input Input consists of several test cases. So, the first line of the input will be N, denoting number of test cases you are going to consider to compute and print number of degrees of dial rotation. Following N, there will be N lines of input, each line contains 4 numbers. Each number will be between 0 and 39 (inclusive). First number of the line is the initial position of the dial. The next 3 numbers are the combination for a lock. Consecutive numbers in a given lock will be distinct. Dial Output For each cases, print a line with a single integer: the number of degrees that the dial must be turned to open the lock.

Step by Step Solution

3.47 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

To solve this problem we need to calculate the total number of degrees the dial needs to be turned t... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago

Question

Briefly describe computer- assisted approaches to production.

Answered: 1 week ago

Question

Why is management of technology important?

Answered: 1 week ago