Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(base, levelHight) {
- let level = 0;
- let stone = 0;
- let marble = 0;
- let lapis = 0;
- let gold = 0;
- while (base > 0) {
- level++;
- if (base === 1 || base === 2) {
- let goldArea = base * base;
- gold = goldArea * levelHight;
- break;
- }
- stone += ((base - 2) * (base - 2)) * levelHight;
- if (level % 5 == 0) {
- let lapisLazuli = ((base - 1) * 4) * levelHight;
- lapis += lapisLazuli;
- } else {
- marble += ((base - 1) * 4) * levelHight;
- }
- base -= 2;
- } let hight = Math.floor(level * levelHight);
- console.log(`Stone required: ${Math.ceil(stone)}`);
- console.log(`Marble required: ${Math.ceil(marble)}`);
- console.log(`Lapis Lazuli required: ${Math.ceil(lapis)}`);
- console.log(`Gold required: ${Math.ceil(gold)}`);
- console.log(`Final pyramid height: ${hight}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement