Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# Another clock problem

Mark Gonsoulin
Greenhorn
Posts: 1
ok here it goes. At 12 noon the second, minute, and hour hand line up perfectly. When is the next time that the three hands will line up perfectly and how did you solve this?

Stefan Wagner
Ranch Hand
Posts: 1923
At 12 midnight.

Assuming the hands don't jump.

The s-hand will meat the others ca. one minute later.
But the m-hand moved more way than the h-hand, and keeps moving faster.
It will get close to the h-hand at about 1 pm, to be more precise at 1:05.
At 1:05:05 the s-hand reaches that position (nearly) too, but the m-hand moved a bit more away, than the h-hand.

This repeats every 1:05:05.

If you calculate the values:

You see the hands would meet again at 11:55:55 and then at 12:60:60 which is 01:01:00.

Pete Kirkham
Greenhorn
Posts: 3
assuming continuous movement:

position of second hand (360 degrees in 60 seconds) = t * 360 / 60 = t * 6;
position of minute hand (360 degrees in 60 * 60 seconds) = t * 360 / (60 * 60) = t / 10;
position of hour hand (360 degrees in 60 * 60 * 12 seconds)= t * 360 / (60 * 60 * 12) = t / 120;

hands meet when
(t*6) % 360 = (t / 10) % 360 = (t / 120) % 360;
or
(t*6) = (t / 10) - a * 360 = (t / 120) - b * 360;
where a, b are integers
(t*6) = (t / 10) - a * 360 ; => 59 t + 3600 a = 0;
(t*6) = (t / 120) - b * 360; => 719 t + 43200 b = 0;

gives two equations that we can eliminate t in:

42421 t + 2588400 a = 0
42421 t + 2548800 b = 0

2588400 a - 2548800 b = 0

so
a = (2548800 / 2588400) b;
=>
a = (708 / 719) b;

so b increments in multiples of 719, and a in 708

back to:
59 t + 3600 a = 0;
gives
t = (708 * 3600 / 59) k, k = {0,1,2...};
t = 43200 k;

every 43200 seconds, or 12 hours.