 0 people like it.

# Calculating the angle between the hour and minute hand

This is a response to a Google interview question that someone encountered. A friend of mine was recently hired there and I've heard some thrilling stories of their interview process. So every now and then, I plan to code up a response to one of the hoards of interview questions they have.

 ``` 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: ``` ``````let calc t = let (h, m) = t let conversion = abs(h - m) * 5.0 * 6.0 if conversion > 180.0 then 360.0 - conversion else conversion (12.0, 0.0) |> calc // 12:00 - should be 0 (12.0, 1.0) |> calc // 12:05 - should be 30 (12.0, 2.0) |> calc // 12:10 - should be 60 (12.0, 3.0) |> calc // 12:15 - should be 90 (12.0, 4.0) |> calc // 12:20 - should be 120 (12.0, 5.0) |> calc // 12:25 - should be 150 (12.0, 6.0) |> calc // 12:30 - should be 180 (12.0, 7.0) |> calc // 12:35 - should be 150 (12.0, 8.0) |> calc // 12:40 - should be 120 (12.0, 9.0) |> calc // 12:45 - should be 90 (12.0, 10.0) |> calc // 12:50 - should be 60 (12.0, 11.0) |> calc // 12:55 - should be 30 (12.0, 12.0) |> calc // 12:00 - should be 0 ``````
val calc : float * float -> float

Full name: Script.calc
val t : float * float
val h : float
val m : float
val conversion : float
val abs : value:'T -> 'T (requires member Abs)

Full name: Microsoft.FSharp.Core.Operators.abs