알고리즘 35 - Will you make it?

tamagoyakii·2021년 10월 13일
0

알고리즘

목록 보기
35/89

Q.

You were camping with your friends far away from home, but when it's time to go back, you realize that your fuel is running out and the nearest pump is 50 miles away! You know that on average, your car runs on about 25 miles per gallon. There are 2 gallons left. Considering these factors, write a function that tells you if it is possible to get to the pump or not. Function should return true (1 in Prolog) if it is possible and false (0 in Prolog) if not. The input values are always positive.

A)

const zeroFuel = (distanceToPump, mpg, fuelLeft) => {
  return fuelLeft >= distanceToPump / mpg;
};

0개의 댓글