Clock Triangles II

Problem #59

Tags: geometry puzzle

Who solved this?

Previous:Clock Triangles Next:Clock Triangles III


Continuing from Stephen's previous boredom with his bedroom clock...

Stephen walks into his kitchen, his boredom temporarily interrupted by hunger. Upon entering the kitchen, he notices that the kitchen clock behaves somewhat differently to the clock in his room. The hands of the kitchen clock do not "tick", but rather move continuously such that the second hand steadily revolves around the entire face every 60 seconds, the minute hand steadily revolves around the entire face every 60 minutes, and the hour hand revolves steadily around the entire face every 12 hours. At no point do any of the hands actually stop moving.

As he watches the hands all move simultaneously at different rates Stephen realizes that any moments where right triangles appear are instantanous and don't remain for any actual time. Similarly, situations where no triangle is formed also exist for only for the exact instant when hands cross each other. However, acute and obtuse triangles may exist and remain for longer periods of time.

Stephen wonders, between a given "start" time and "end" time, what percentage of that time would an acute triangle be showing on the clock?

Problem Statement

Given a start time and an end time, return the percentage of the time that an acute triangle would be formed by the ends of the equally-sized hands. Times are again given in the format HH:MM:SS, and again only the period between the two times should be considered.

Again note that all times are given using the 12-hour format. It should be understood that 4 hours would pass between 10:00:00 and 02:00:00.

Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each with two space-separated time values t_start and t_end.

Answer
Should consist of Q space-separated integers, corresponding to the percentage of time between the specified times in each testcase during which an acute triangle would be formed by the clock.
Report percentages as decimals. For example, 50% should be reported as 0.5.
Answers should be accurate to 1e-6.

Example

input data:
4
10:29:22 10:29:23
10:29:21 10:29:24
10:29:20 02:34:56
12:00:01 12:00:00

answer:
0.447844 0.482615 0.237591 0.249974
You need to login to get test data and submit solution.