SHARE
TWEET

Untitled

a guest May 23rd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve (base, increment) {
  2.     let marble = 0;
  3.     let stone = 0;
  4.     let lazuli = 0;
  5.     let gold = 0;
  6.     let counterSteps = 0;
  7.  
  8.     function computePyramid(remainder){
  9.         for (let i = base; i >= 1; i -= 2) {
  10.             counterSteps++;
  11.             if (counterSteps % 5 !== 0 && i !== remainder) {
  12.                 marble += (i * 4) - 4;
  13.                 stone += (i-2) * (i-2);
  14.             } else if (counterSteps % 5 === 0 && i !== remainder) {
  15.                 lazuli += (i * 4) - 4;
  16.                 stone += (i-2) * (i-2);
  17.             } else if (i === increment) {
  18.                 gold = increment * increment;
  19.             }
  20.         }
  21.     }
  22.    
  23.     computePyramid(base % 2 ? 2 : 1);
  24.     console.log (`Stone required: ${Math.ceil(stone*increment)}\nMarble required: ${Math.ceil(marble*increment)}\nLapis Lazuli required: ${Math.ceil(lazuli*increment)}\nGold required: ${Math.ceil(gold*increment)}\nFinal pyramid height: ${Math.floor(counterSteps*increment)}`);
  25. }
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