Advertisement
Spocoman

Deer of Santa

Feb 13th, 2022 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function deerOfSanta(input) {
  2.  
  3.     let days = Number(input[0]);
  4.     let foods = Number(input[1]);
  5.     let deer1 = Number(input[2]);
  6.     let deer2 = Number(input[3]);
  7.     let deer3 = Number(input[4]);
  8.  
  9.     let neededFood = (deer1 + deer2 + deer3) * days;
  10.  
  11.     if (foods >= neededFood) {
  12.         console.log(`${Math.floor(foods - neededFood)} kilos of food left.`);
  13.     } else {
  14.         console.log(`${Math.ceil(neededFood - foods)} more kilos of food are needed.`);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement