Using Javascript, together a software developer I\"ll shot to price interview inquiry \"How many times a work a clock\"s hands overlap?\" v the exact overlapping time of the clock\"s hour hand and also minute hand.This tricky question was inquiry by my manager to among our intern university student.Later us learnt that this concern \"How numerous times carry out a clock\"s hand overlap in a day?\" is one interview question asked for project applicants in Google.

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

Let\"s an initial analyze the difficulty of overlapping clock\"s hour and also minute hands.First collection our imaginary clock come 12:00 midnight i beg your pardon is the beginning time because that the troubles time period.


As you watch at start time when the duration for calculation start we have an overlapping problem for clock\"s hour hand and also minute hand.

Now assume that the clock\"s hour and also minute hands overlap because that the next time.The first overlapping ~ 12:00 o\"clock will happen between 1 o\"clock and also 2 o\"clock.But we execute not understand the specific time right currently at this stage of the trouble solution.


Let\"s study the above situtation now. Very first of all, clock\"s hour hand only relocated from position 12 come a position in between 1 and also 2. What is interesting for the solution of this inteview concern is that at the very same time period, the minute hand that the clock perfect a full cycle starting from 12 to 12 and furthermore traveled the exact same distance together hour hand at the overlapping time.

Here is a drawing displaying the case visually to aid you know the hint for the systems of \"how plenty of times a day a clock\"s hands overlap?\".


We have actually one base mathematical equation for this problem that will certainly lead us to solution.The minute hand is 12 times much faster than the hour hand.If girlfriend think of the moment passing native 12:00 o\"clock to 1 o\"clock, the minute hand travel 360 degrees. At the same time the hour hand travel 1/12 the 360 degrees.Or in a various thinking, in a particular time period (t) minutes, the minute hand travels (360 * t) / 60 degreesBut in ~ the very same time the hour hand just travels 1/12 of that degree: (360 * t) / (60 * 12) degrees.

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

So we deserve to now say that while hour hand travel (n) levels the minute hand will take trip (12*n) degrees.The result that will outcome from this added equation with first mathematical equation will be together follows:

12 * n = 360 + n

Of food 360 levels is true if only 1 hour has passed.If two hrs passed, then the formula will be: 12 * n = 360*2 + nSo we have the right to re-formulate the equation as follows:

12 * n = 360 * h + n

Now replace n the degree the hour hand traveled over 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 first hour we deserve to replace h with 1 and also we can solve the equation for very first overlap after 12:00 o\"clock

t = 720 /11 = 65,45 minutes

There is an various other tricky conversion right here the decimal component of the time. We require to transform it to seconds.

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

So the first overlap is at 65 minute 27 seconds later on which method 1:05:27

Then us can continue calculation for the 2nd overlap the clock\"s hands. This will certainly occur between 2 o\"clock and 3 o\"clock.This way minute hand that the clock will take trip 2 times complete circle and plus the exact same amount together hour hand.

Now I desire to move all these calculations into listed below Javascript code

Javascript Code

Here are some sample Javascript codes calculating the times once the clock\"s hands overlap in a dayPlease keep in mind that the listed below Javascript password is listed by Hilal �etinkaya, our intern student. Many thanks a lot for her assist for the systems of this exciting problem.

There is a Javascript Loop framework to calculate each time the minute hand completes a complete cycle.Since in a day the pattern from midnight it spins noon will be same for the second half of the job (from noon till midnight), the Javascript loop is characterized for an essence variable beginning 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 + \":\" + secs + \"\");}

Within the loop, every overlap problem is calculated utilizing the math equation discussed in previous section.For loop structure contains mod functions and also Mart.floor() features for converting the moment in minute to hours:minutes:seconds screen format.

See more: How Many Cups Of Uncooked Rice Does One Cup Of Dry Rice Make?

As you check out in the output of this sample Javascript code, an initial overlap wake up at 00:00:00 o\"clock.And the critical overlap that clock\"s hand will take place at 24:00:00To price the interview inquiry \"How numerous times a job a clock\"s hand overlap?\", an initial of all us should identify if first overlap time the is the beginning time counts or not.I assume the we can agree the start time is also one of the overlapping times in a day.So, 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 occurs at 01:05:273. Time overlap occurs at 02:10:544. Time overlap occurs at 03:16:215. Time overlap occurs at 04:21:496. Time overlap occurs 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 occurs at 10:54:3212. Time overlap wake up at 12:00:0013. Time overlap occurs at 13:05:2714. Time overlap wake up at 14:10:5415. Time overlap occurs at 15:16:2116. Time overlap occurs at 16:21:4917. Time overlap occurs at 17:27:1618. Time overlap occurs at 18:32:4319. Time overlap wake up at 19:38:1020. Time overlap wake up at 20:43:3821. Time overlap wake up at 21:49:0522. Time overlap wake up at 22:54:3223. Time overlap wake up at 24:00:00 (since we count beginning as one of overlaps, this could be excluded)

As a result, if you counting the last case, there space 23 times once a clock\"s hour and minute hand overlap in a day.If girlfriend exclude among the midnights, we deserve to conclude the there space 22 times when a clock\"s hands overlap in a day.