SHARE
TWEET

Untitled

a guest Feb 22nd, 2020 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.   let cells = input.shift().split("#");
  3.   let water = input.shift();
  4.   let putOutCells = [];
  5.   let totalFire = 0;
  6.   let totalEffort = 0;
  7.  
  8.  for (let i = 0; i< cells.length; i++) {
  9.       let [level, value] = cells[i].split(" = ");  
  10.      value = Number(value)
  11.      if (level === "High" && (value >= 81 && value <= 125) && water >= value) {
  12.       totalEffort+= value * 0.25;
  13.       water-= value;
  14.       totalFire+=value;
  15.       putOutCells.push(value);
  16.      } else if (level === "Medium" && (value >= 51 && value <= 80) && water >= value) {
  17.       totalEffort+= value * 0.25;
  18.       water-= value;
  19.       totalFire+=value;
  20.       putOutCells.push(value);
  21.      } else if (level === "Low" && (value >= 1 && value <= 50) && water >= value) {
  22.       totalEffort+= value * 0.25;
  23.       water-= value;
  24.       totalFire+=value;
  25.       putOutCells.push(value);
  26.      }
  27.   }
  28.  
  29.   console.log("Cells:");
  30.   putOutCells.forEach(e => console.log(` - ${e}`))
  31.   console.log(`Effort: ${(totalEffort).toFixed(2)}`);
  32.   console.log(`Total Fire: ${totalFire}`);
  33.  
  34.  
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top