Advertisement
ErolKZ

Untitled

Sep 17th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1.  
  2. function solve(base, incr) {
  3.  
  4.  
  5. let counter = 0;
  6.  
  7. let stone = 0;
  8.  
  9. let marble = 0;
  10.  
  11. let lapis = 0;
  12.  
  13. let aeria = 0;
  14.  
  15. let gold = 0;
  16.  
  17.  
  18.  
  19. while (base > 0) {
  20.  
  21. counter++;
  22.  
  23.  
  24.  
  25. if (base <= 2) {
  26.  
  27. gold = (base * base) * incr;
  28.  
  29. break;
  30.  
  31. }
  32.  
  33. base = base - 2;
  34.  
  35. aeria = base * base;
  36.  
  37. stone += aeria * incr;
  38.  
  39. if (counter % 5 === 0) {
  40.  
  41. lapis += ((2 * (base + base + 4)) - 4) * incr;
  42.  
  43. } else {
  44.  
  45. marble += (((base + 2) * (base + 2)) - aeria) * incr;
  46.  
  47. }
  48.  
  49.  
  50. }
  51.  
  52.  
  53.  
  54.  
  55. console.log(`Stone required: ${Math.ceil(stone)}`);
  56.  
  57. console.log(`Marble required: ${Math.ceil(marble)}`);
  58.  
  59. console.log(`Lapis Lazuli required: ${Math.ceil(lapis)}`);
  60.  
  61. console.log(`Gold required: ${Math.ceil(gold)}`);
  62.  
  63. console.log(`Final pyramid height: ${Math.floor(counter * incr)}`);
  64.  
  65.  
  66.  
  67.  
  68. }
  69.  
  70.  
  71. console.log(solve(11, 1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement