Monday, January 28, 2013

Interview: Calculate the angle of analog clock

Calculate the angle of two clock pointers when time is 11:50


Continuing with some of the questions from Glassdoor's top 25 oddball questions... I am skipping around to whichever I find interesting. A couple of them are pretty common and already have rather standard answers. So, I picked this one because this turned out to have an extra step than what I originally thought.

Humor
Before I get to the common response, try one of the following if you're feeling lucky (disclaimer: make sure interviewer has the proper sense of humor)... the angle is the difference between meeting a deadline and getting fired... 0 degrees because it takes you 10 minutes to solve it... 90 or 180 on a digital clock... null, pointers have no direction in [programming language].

My Thought Process
At first glance, I thought the answer was 60 degrees because 11:50 is 10 minutes before noon/midnight. 10 minutes of 60 minutes in an hour = 1/6. Clock is 360 degrees, so 60 degrees. Then made a sanity check by trying to picture the clock at 11:50.

I quickly realized that the hour hand would not exactly be at the o'clock position. The hour hand would be slightly before the 0 degree (assuming o'clock is my reference). Each hour move 30 degrees (because each hour is the distance as 5 minutes which is half of 10 minutes). Thus for each minute, the hour hand would move 1/60 of 30 degrees, 0.5 degree.

The answer would be 60 degrees - 0.5 degrees * 10 minutes. Final answer is 55 degrees.

Additional Follow Up
A good potential follow up to this may be to provide the general equation (ie function, method, etc.) to generate the value for any time. Given X minutes and Y hours with noon as the 0 degree reference, the minutes degree will be X / 60 * 360 = X * 6 and hours degree will be X / 2 + 30 * Y. Thus, the final equation is |X * 6 - (X / 2 + 30 * Y)|. Test with original points, |50 * 6 - (50 / 2 + 30 * 11)| = |300 - (25 + 330)| = |-55| = 55. Test with 12:10, |10*6 - (10 / 2 + 30 * 0)| = |60 - (5 + 0)| = 55. Simplify the equation, | X * 5.5 + Y * 30|.

Add constraints... 0 <= Y < 24 and 0 <= X < 60. Y must be an integer; X must be a real number. If Y >= 12, then Y = Y - 12.

Some extra thoughts... If a graphic artist, then provide a time entry GUI. If animator, provide equation for reference to 3D space (ie angle if clock is angled at certain positions). If math, provide equation if only provided the positions of the two lines. If high school degree, use approximation because you should know that 3 and 9 are right angles so 90 degrees, so 10 (i.e. 50 minutes) and 11 breaks the 90 degrees into thirds, thus each hour is 30 degrees which gives you 60 degrees minus a few degrees. If physics, then ask about the velocity the clock is traveling at.

30 Degrees?


Guesstimation

Assuming you have figured there are 30 degrees between each hour, you can see that the answer must be greater than 30 degrees. From looking at the image above, you can see that the answer should be closer to 60 degrees. You will also notice that the hour hand is not exactly at the 12 mark. Therefore, the answer is less than 60 degrees. Mathematically, you should be able to estimate that the answer is between 30 and 60 degrees. If you eye ball the difference, you should be around 50-55 because 45 degrees would be symmetrically in the middle.

Misconception

I found that 30 degrees was a common answer to this question. This primarily comes because the image is of the hour hand on the 11 mark and the minute hand on the 10 mark. What is not considered is that the hour hand moved past the 11 mark due to the minute hand moving to the 10 mark.

Fortunately for me, my thought process was going from noon and going back 10 minutes. So I naturally picked up that the position of the hour hand was impacted by the minute hand. This is why I typically do a sanity check particularly with questions that appear simple but you get an uneasy feeling there is something amiss. For example, why would they be asking a simple geometric question in an interview? Or in this example, why would this be a top 25 list of oddball questions if the answer is so direct?

Reference

http://www.techrepublic.com/blog/career/glassdoors-top-25-oddball-interview-questions-for-2013/4783

Updated 1/24/2014 - Added section for 30 degrees to explain how the answer is not 30 degrees.

2 comments:

  1. WOW!!
    how many degrees has a circle (clock or a pie if you want) 360 degree, agreed!?
    ....in how many parts is the clock (circle..pie) divided...in 12
    ...so 360:12 = 30 degree each slice of clock pie... 11:50 is a whole slice

    ReplyDelete
    Replies
    1. I've updated the post to explain why the answer is not 30 degrees.

      Delete