Advertisement
Spocoman

Easter Bake

Feb 21st, 2022 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterBake(input) {
  2.     let quantity = Number(input.shift());
  3.     let sugarTotal = 0;
  4.     let flourTotal = 0;
  5.     let maxSugar = 0;
  6.     let maxFlour = 0;
  7.  
  8.     for (let i = 0; i < quantity; i++) {
  9.         let sugar = Number(input.shift());
  10.         let flour = Number(input.shift());
  11.         if (maxSugar < sugar) {
  12.             maxSugar = sugar;
  13.         }
  14.         if (maxFlour < flour) {
  15.             maxFlour = flour;
  16.         }
  17.         sugarTotal += sugar;
  18.         flourTotal += flour;
  19.     }
  20.  
  21.     console.log(`Sugar: ${Math.ceil(sugarTotal / 950)}`);
  22.     console.log(`Flour: ${Math.ceil(flourTotal / 750)}`);
  23.     console.log(`Max used flour is ${maxFlour} grams, max used sugar is ${maxSugar} grams.`);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement