 # CLOCK:

Tester: Sangram Desai

SIMPLE

# PROBLEM:

Given time in HH MM SS format and you have to find what will be time after hour hand moves by x degrees.

# EXPLANATION:

If hour hand moves by 1 degree then 2 minutes will happen in 12 hour clock. As x is integer and smallest change in x can be only 1 degree hence
second hand will come to its original position whatever may be the value of x i.e SS field will not change.
Now find if minutes to add in MM field is greater than 60 or not . If final MM field > 60 then add extra minutes in hour by converting minutes to
hour.

Note : if x > 360 that means hour hand has moved by more than 360 degrees i.e several complete rotations have happened.
so to solve one can do x = x%360 which will have same effect.

Possible testcases where you may get wrong answers:

input :

6

11 58 59 1

11 59 1 1

12 58 55 28

11 2 23 29

11 2 0 361

11 59 27 62

output:

12 0 59

12 1 1

1 54 55

12 0 23

11 4 0

2 3 27

# AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution Java Solution

Tester’s solution Python Solution.

3 Likes

The preliminary step here is to find out what 1 degree motion of the hour hand means in terms of time. 0ne full rotation of the hour hand is 12 hours or 12\times 60 = 720 minutes, and conveniently we have 720/360 = 2 exactly; giving 2 minutes per degree.

If, instead of degrees, the question had asked the time after the hour hand is moved by x gradians, which have 400 for a full turn, we would have had to go down to an effect in seconds, with 720\times 60 = 43200 second in a full turn of the hour hand and thus 108 seconds per gradian.

1 Like

@joffan Thanks for your suggestion about use of gradians in problem . But I wanted to design an easy problem So I deliberately made a special case in which that it turns out that 1 degree corresponds to 2 minutes.

So bonus question : x can be negative

Oh sure, I wasn’t complaining at all about the use of degrees. Just pointing out where the 1 degree = 2 minutes comes from.

And my alternative example was gradians not radians - they would be much more difficult since a full turn in radians is 2\pi.

PS: re bonus question: my code already worked correctly. 1 Like