Kalido Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
Thank you avenger ...this is my highest rated answer in Careercup . Thanks for the upvote :)
I think your answer is wrong. The angle between 0(midnight) - 6 and then 6 and 12 is 180 degrees.
50 minutes is when minutes hand is pointing 10. As you wrote an hour hand elapses 30 degrees for every hour.
So the angle is 180 - 60 = 120 degrees.
Here is how I see it:
6.00 - 180 degrees (hour hand points 6 and minutes hand points 12)
6.55 - 150 degrees
6.50 - 120 degrees
6.45 - 90 degrees
6.40 - 60 degrees
6.35 - 30 degrees
6.30 - 0 degrees (both hands points to 6 hour)
@thelineofcode your thinking is wrong. at 6:00 its is 180 deg but at 6:55, its not 150 deg as the MINUTES hand is less by 5 min(its not HOUR's hand). And you will also have an offset there as the hour's hand wont be pointing at 7 exactly..it will be very close to 7 but not 7. Please watch your clock more carefully
For hour hand,
1 hour = (360/12) = 30 degrees movement
1 minute = (30/60) = 0.5 degree movement
For minute hand,
1 minute = (360/60) = 6 degrees movement
So, if time is H:M
Angle between two hands = |((30*H)+(0.5*M))-(6*M)|
6:50 will give 95 degrees
Hey guys. My math skills suck but please explain why wouldn't it be 120°, since it's the only answwer I coud actually explain to my interviewer.
- At 6:50, the minute hand is sitting on 10 and the hour hand is just shy of sitting on the 6.
- There are 12 hours in 360*, so one hour = 360/12 = 30 deg
- The angle between 6 and 10 = (10 -6) * 30 = 120 deg
- The hour hand is 10/12 of the way from the 5 to the 6:
30 * 10 / 12 = 25 deg
So the hour hand is 30 - 25 = 5 deg away from the 6.
- Total angle between hour & minute hand = 120 + 5 = 125 deg
I also got 95 degrees. Here's how.
Suppose the hour and minute hands were pointing to 6:00, then there's a 180 degree angle since it's a straight line.
Now, return to the time of 6:50. The minute hand sits on the 10. For each increase in number, there is a 360/12 = 30 degree rotation. So the angle between the 12 and 10 is 2*30 = 60 degrees.
Now consider the angle between the hour hands at 6:00 and 6:50. This is 5/6 of an hour, or 5/6 of a number change. Thus, the angle is 30*(5/6) = 5*5 = 25 degrees.
Since 12:00 and 6:00 make a straight line (180 degrees), we have
60 + x + 25 = 180
x = 180 - 60 - 25
x = 95
Kind of a long response. But easy to explain.
Hour hand:
Rotates by 360 degrees in = 12 hours
In an hour = in 60 minutes = 360/12 = 30 degrees
in a minute = 30/60 = .5 degree
In 6 hours = 30 * 60 = 180 degrees
in 50 minutes = 50 *.5 = 25 degrees
in 6 hours 50 minutes = 180 +25 degrees
Minute hand:
Rotates 360 degrees = 60 minutes
1 minute = 360/60 = 60 degrees
in 50 minutes = 300 degrees
Difference between the two hands in degrees = 300 -205 = 95 degree
/* This is program to find the angle between Hour Hand and Minute Hand*/
#include<stdio.h>
#include<math.h>
int main()
{
int hour = 2;// totally 360 degrees ,12 hours(760 Minutes) = 360 degress, 1 minute = 0.5 degress
int minute =20;// totally 360 degrees ,60 minutes = 360 degress, 1 minute = 6 degress
int degree = 0;
hour = (hour*60+minute)/2;
minute=(minute*6);
printf(" The angle betwenn hour and minute hand is %d\n",hour-minute);
return 0;
}
Answer should be 95 degress.
A method to solve such problems is to consider the rate of change of the angle in degrees per minute. The hour hand of a normal 12-hour analogue clock turns 360° in 12 hours (720 minutes) or 0.5° per minute. The minute hand rotates through 360° in 60 minutes or 6° per minute.
Angle b/w hour and minute hand is => ½ *(total minutes) - 6 * minutes
for 6:50 then angle will be
½*(6*60 + 50) - 50*6 => ½ * (410) - 3000 => 205-300 => 95 degrees
I'm reading Cracking the coding interview and she suggests the answer is (30h - 5.5m) % 360 but I did not understand how she got that and I tried some tests and maybe i'm mistaken but it doesn't seem to work.
My thinking was that if you consider noon to be 0 and you first look for the angle of the hour hand from 0 and get that number and then do the same thing for the minute hand and then subtract the two you would get your answer (ofcourse checking if the angle was greater than 180 and if so subtracting by 360 to get the smaller angle).
So at 1 PM, the hour hand is at 1 and the angle from noon is 360/12 = 30.
And at 12:01 pm, the minute hand is at 1 minute and the angle from noon for the minute hand is 360/60 = 6.
can someone tell me if this is the right or wrong answer?
static int GetAngle(int h, int m)
{
int hAngle = 30 * (h % 12);
int mAngle = 6*m;
int diff = Math.Abs(hAngle-mAngle);
if (diff > 180)
{
diff = 360 - diff;
}
return diff;
}
public class Angle {
public static void main(String args[]){
float hr=12; //time hour
float min=5; //time minute
if (hr>=12){
hr-=12;
}
float ang=360/60; //Unit Angle
float mv=(float)5/60; //Hour hand movement per minute
float hr1=hr*5+mv*min; //Hour hand position
System.out.println("hr1: "+hr1);
if(hr1>min){
float temp=hr1-min;
System.out.println("Angle="+temp*ang);
}
else{
float temp=min-hr1;
System.out.println("Angle="+temp*ang);
}
}
Hour hand angle for a hour= 360/12=30deg
Hour hand angle for a min=360/(12*60)=0.5deg
Min hand angle for a minute= 360/60=6 deg
Hour hand moves 30 deg for an hour and 0.5 deg for min
Minute hand moves 6 deg for min
Hour hand angle = (6*30)+(0.5*50)=205deg
Minute hand angle=(50*6)=300deg
Angle between= 300-205=95deg
The angle between hours and minutes for a given time x:y(x hours and y minutes) is |30*x-11*y/2|(absolute value)..this comes from the fact that a hour hand elapses 30 degrees for every hour(360/12) and minute hand elapses 6 degrees(360/60)..but for 6:50,the hour hand also elapses extra offset from its original position where it has to be there at 6:00 sharp..the offset is calculated as follows:
- Karthik vvs October 23, 20121.for every 60 minutes of minutes hand,hour hand elapses 1 hour..so distance travelled by hour hand when the minute hand travels 1 min is 1/60
2.so the offset is (50/60)*30 degrees for the hour hand
3.so the total angle covered by hour hand for 6:50 is 6*30 degrees+offset=180+25=205 degrees
4.angle covered by minute hand is 50*6 degrees=300 degrees
So,angle between them =300-205=95 degrees :)