I have heard of this question coming up a little bit in all sorts of technical interviews so I thought I would set it as a G Challenge.
Question:
“Please tell me what you would implement to tell me the angle between then hands on a watch face at any given time of the day. Please show your working and use these examples.”
6:00, 3:00, (lets make this non trivial now ) 9:15, 1:30 12:50, 3:20.
Answer Style:
It is up to you how you go about answering this, but I would try this in two stages.
- Have a pen and paper and go about it as if you were in an interview, then :
- Actually try to write some VBA for a spreadsheet that goes about doing it. Esp if you can call it from the sheet so your function returns the answer from an Excel Date Time entered in a cell.
Extra Homework:
- Could you write this as a VB dll, C++ dll, C# XLL etc?
- Does your function cope with 24hr time format?
- Can you also output a list of times from an angle? Ie. what times equate to 90 deg, 27 deg etc?
- If so can you output this as an array function so that a list can be shown in Excel?