Using Javascript, as a software application developer I"ll shot to price interview question "How countless times a work a clock"s hands overlap?" through the precise overlapping time of the clock"s hour hand and also minute hand.This tricky concern was request by mine manager to one of our intern college student.Later we learnt the this question "How plenty of times perform a clock"s hand overlap in a day?" is one interview concern asked for task applicants in Google.

You are watching: How many times a day clock hands overlap

Let"s first analyze the trouble of overlapping clock"s hour and minute hands.First set our imaginary clock come 12:00 midnight which is the beginning time for the difficulties time period.


As you watch at begin time when the duration for calculation starts we have an overlapping condition for clock"s hour hand and minute hand.

Now assume that the clock"s hour and also minute hand overlap because that the following time.The very first overlapping ~ 12:00 o"clock will certainly happen between 1 o"clock and 2 o"clock.But we do not recognize the exact time right now at this phase of the problem solution.


Let"s examine the above situtation now. Very first of all, clock"s hour hand only relocated from place 12 come a position between 1 and also 2. What is interesting for the solution of this inteview concern is that at the same time period, the minute hand that the clock completed a complete cycle starting from 12 come 12 and in addition traveled the same distance as hour hand at the overlapping time.

Here is a drawing displaying the situation visually to assist you understand the hint for the solution of "how plenty of times a work a clock"s hand overlap?".


We have one basic mathematical equation for this difficulty that will certainly lead united state to solution.The minute hand is 12 times faster than the hour hand.If you think of the time passing from 12:00 o"clock to 1 o"clock, the minute hand travels 360 degrees. Meanwhile the hour hand travels 1/12 that 360 degrees.Or in a various thinking, in a specific time duration (t) minutes, the minute hand travel (360 * t) / 60 degreesBut in ~ the exact same time the hour hand only travels 1/12 of the degree: (360 * t) / (60 * 12) degrees.

An other equation comes from the pass hours. Every passing hour the minute hand completes a complete cycle.Let"s say the the hour hand traveled (n) degrees. For this reason we have the right to say at as soon as they overlap each various other the minute hand travel (360 + n) degrees at the same time together hour hand.

So we have the right to now say the while hour hand travel (n) degrees the minute hand will take trip (12*n) degrees.The an outcome that will outcome indigenous this additional equation with an initial mathematical equation will be as follows:

12 * n = 360 + n

Of course 360 levels is true if just 1 hour has passed.If two hours passed, then the formula will certainly be: 12 * n = 360*2 + nSo we deserve to re-formulate the equation together follows:

12 * n = 360 * h + n

Now change n the level the hour hand traveled with time t, (360*t)/(60*12)

12 * (360*t)/(60*12) = 360 * h + (360*t)/(60*12)11 * (360*t)/(60*12) = 360 * h11 * t / 2 = 360 * h11 * t = 720 * h

For very first hour we can replace h with 1 and we deserve to solve the equation for an initial overlap after ~ 12:00 o"clock

t = 720 /11 = 65,45 minutes

There is an other tricky conversion right here the decimal part of the time. We need to convert it to seconds.

0,45 minute = 45/100 minute = 45*60/100 seconds= 27 seconds

So the first overlap is at 65 minutes 27 seconds later which way 1:05:27

Then we can proceed calculation because that the 2nd overlap that clock"s hands. This will occur in between 2 o"clock and also 3 o"clock.This method minute hand the the clock will travel 2 times complete circle and plus the exact same amount together hour hand.

Now I desire to relocate all this calculations into below Javascript code

Javascript Code

Here room some sample Javascript password calculating the times when the clock"s hand overlap in a dayPlease note that the listed below Javascript password is listed by Hilal �etinkaya, our intern student. Many thanks a lot because that her help for the systems of this exciting problem.

There is a Javascript Loop structure to calculation each time the minute hand completes a complete cycle.Since in a day the pattern from midnight it rotates noon will be exact same for the second fifty percent of the job (from noon till midnight), the Javascript loop is identified for an creature variable starting from 0 to 11.

var t, n, temp1, temp2;var hour, minutes, seconds;for (t = 0; t n = 720 * t / 11;var n = Math.round(n * 100) / 100;hour = Math.floor(n / 60);minutes = Math.floor(n) % 60;temp1 = n * 100;temp2 = temp1 % 100;seconds = Math.floor((temp2 * 60) / 100);document.write( (t+1) + ". Time overlap wake up at " + hour + ":" + minutes + ":" + seconds + "");}

Within the loop, each overlap condition is calculated utilizing the mathematics equation discussed in ahead section.For loop structure includes mod functions and Mart.floor() features for converting the moment in minute to hours:minutes:seconds display format.

See more: What Phylum Is A Spider In? Insects, Spiders, Centipedes, Millipedes

As you watch in the calculation of this sample Javascript code, very first overlap wake up at 00:00:00 o"clock.And the last overlap of clock"s hand will occur at 24:00:00To price the interview concern "How countless times a job a clock"s hand overlap?", very first of all us should identify if an initial overlap time the is the starting time counts or not.I assume the we deserve to agree the begin time is likewise one of the overlapping time in a day.So, right here is the times count and also clock"s hand overlap time within 24 hours:1. Time overlap occurs at 00:00:002. Time overlap wake up at 01:05:273. Time overlap occurs at 02:10:544. Time overlap wake up at 03:16:215. Time overlap wake up at 04:21:496. Time overlap wake up at 05:27:167. Time overlap wake up at 06:32:438. Time overlap occurs at 07:38:109. Time overlap wake up at 08:43:3810. Time overlap wake up at 09:49:0511. Time overlap wake up at 10:54:3212. Time overlap occurs at 12:00:0013. Time overlap occurs at 13:05:2714. Time overlap occurs at 14:10:5415. Time overlap wake up at 15:16:2116. Time overlap occurs at 16:21:4917. Time overlap wake up at 17:27:1618. Time overlap occurs at 18:32:4319. Time overlap occurs at 19:38:1020. Time overlap wake up at 20:43:3821. Time overlap occurs at 21:49:0522. Time overlap occurs at 22:54:3223. Time overlap wake up at 24:00:00 (since we count starting as among overlaps, this can be excluded)

As a result, if you counting the critical case, there room 23 times once a clock"s hour and also minute hands overlap in a day.If girlfriend exclude one of the midnights, we have the right to conclude the there room 22 times once a clock"s hand overlap in a day.