Epic Systems Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Written Test
The hill length is 60.5 feet . So at 57th minute it will reach at 60 feet and falling down to 57 feet. Next 58th minute it will reach to 60.5 feet becoz the hill is 60.5 feet long.It cannot go beyond 60.5 height. So it has reached at 60.5 feet already at 58th minute.Dont consider falling down at the last step.So answer can be 58 minutes.
You are all wrong.
Consider that the Bear will reach the top of the hill before falling down. Ie: if the hill were 3 feet, the bear would reach the top of the hill in 1 minute (of course, it would then fall 2 feet afterward, but still). A 4 foot hill would take 2 minutes (it climbs 3, falls 2 then climbs 3 more). Making a formula, the bear would effectively take the following time to climb any hill:
public static void double climbTime(double hillHeight){
if(hillHeight < 3.0){
return hillHeight/3.0;
}
return 1.0 + (hillHeight-3.0)
}
public static int computeTime(Double height ){
if (height % 3 == 0){
return (height-3)+1;
}
else{
return (height/3+1);
}
}
public static int computeTime(double height){
if(height<=3) return height/3;
else if (height % 3 == 0) return (height-3)+1;
else return (height/3)*3+(height%3)/3.0;
}
This code should be right
The effective distance travelled by the bear in 58 minutes is 58 feet.So,to reach the 60.5 feet mark it needs to travel 2.5 feet more .Assuming that the bear does not fall down by 2 feet for climbing anything less than 3 feet it takes the bear (2.5/3)*60 seconds to traverse the remaining distance.
Total time taken= 58 minutes and 50 seconds.
#include <stdio.h>
float climbtime(float);
int main()
{
float h,t;
printf("Enter height of mountain");
scanf("%f",&h);
t=climbtime(h);
printf("The time taken to climb is %f",t);
}
float climbtime(float height)
{
int flag;
float temp;
for( flag=1;flag<height;flag++)
{
if((height-flag)< 3)
{
temp=height-flag;
break;
}
else
continue;
}
return flag+((float)temp/3);
}
The effective speed of beer is 1 foot/min , so it will take 58 minutes to climb 58 feet , then assuming his climbing speed to be uniform it will take 0.8 min to climb the next 2.5 feet. So , total time is 58.8 minutes or 59 minutes if you round it.
- praveenkcs28 October 27, 2014